forked from sorccu/node-jpeg-turbo
-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathindex.js
38 lines (33 loc) · 1.15 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
const binding = require("pkg-prebuilds")(
__dirname,
require("./binding-options")
);
// Copy exports so that we can customize them on the JS side without
// overwriting the binding itself.
Object.keys(binding).forEach(function (key) {
module.exports[key] = binding[key];
});
// Convenience wrapper for Buffer slicing.
module.exports.compressSync = function (buffer, optionalOutBuffer, options) {
var out = binding.compressSync(buffer, optionalOutBuffer, options);
return out.data.slice(0, out.size);
};
// Convenience wrapper for Buffer slicing.
module.exports.compress = function (a, b, c) {
return binding.compress(a, b, c).then((out) => {
return out.data.slice(0, out.size);
});
};
// Convenience wrapper for Buffer slicing.
module.exports.decompressSync = function (buffer, optionalOutBuffer, options) {
var out = binding.decompressSync(buffer, optionalOutBuffer, options);
out.data = out.data.slice(0, out.size);
return out;
};
// Convenience wrapper for Buffer slicing.
module.exports.decompress = function (a, b, c) {
return binding.decompress(a, b, c).then((out) => {
out.data = out.data.slice(0, out.size);
return out;
});
};