-
Notifications
You must be signed in to change notification settings - Fork 87
/
index.js
46 lines (36 loc) · 1.06 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var binary = require('@mapbox/node-pre-gyp');
var path = require('path');
var binding_path = binary.find(path.resolve(path.join(__dirname,'./package.json')));
var tulind = require(binding_path);
var make_call = function(ind) {
var index = ind.index;
return function(inputs, options, callback) {
if (arguments.length < 3) {
return new Promise(function(resolve, reject) {
tulind.callbyindex(index, inputs, options, function(err, result) {
return err ? reject(err) : resolve(result);
});
});
} else {
return tulind.callbyindex(index, inputs, options, callback);
}
};
};
var make_start = function(ind) {
var index = ind.index;
return function(options) {
return tulind.startbyindex(index, options);
};
};
var indicators = tulind.indicators;
for (var key in indicators) {
var ind = indicators[key];
if (typeof ind.indicator == 'function') break;
ind.indicator = make_call(ind);
ind.start = make_start(ind);
delete ind.index;
}
module.exports = {
indicators: indicators,
version: tulind.version
};