-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathindex.js
More file actions
20 lines (17 loc) · 721 Bytes
/
Copy pathindex.js
File metadata and controls
20 lines (17 loc) · 721 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var binding = require('bindings')('jpegturbo.node')
// 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.decompressSync = function(buffer, optionalOutBuffer, options) {
var out = binding.decompressSync(buffer, optionalOutBuffer, options)
out.data = out.data.slice(0, out.size)
return out
}