-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
31 lines (26 loc) · 1.46 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
var binding = require('./build/Release/rrdjs_bindings');
exports.create = function(fn, step, start, args, next) {
var a = parseInt(start), b = parseInt(step);
if (isNaN(a)) throw new Error("expected numeric start in rrdjs#create");
if (isNaN(b) || b <= 0) throw new Error("expected positive step in rrdjs#create");
if (!Array.isArray(args)) throw new Error("expected args array in rrdjs#create");
if (typeof next !== 'function') throw new Error("expected callback function in rrdjs#create");
return binding.create(fn, b, a, args, next);
}
exports.info = function(fn, next) {
if (typeof next !== 'function') throw new Error("expected callback function in rrdjs#update");
return binding.info(fn, next);
}
exports.update = function(fn, tmpl, args, next) {
if (!Array.isArray(args)) throw new Error("expected args array in rrdjs#update");
if (typeof next !== 'function') throw new Error("expected callback function in rrdjs#update");
return binding.update(fn, tmpl, args, next);
}
exports.fetch = function(fn, cf, start, end, step, next) {
var a = parseInt(start), b = parseInt(end), c = parseInt(step);
if (isNaN(a)) throw new Error("expected numeric start in rrdjs#fetch");
if (isNaN(b)) throw new Error("expected numeric end in rrdjs#fetch");
if (isNaN(c) || c <= 0) throw new Error("expected positive start in rrdjs#fetch");
if (typeof next !== 'function') throw new Error("expected callback function in rrdjs#fetch");
return binding.fetch(fn, cf, a, b, c, next);
}