-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
34 lines (30 loc) · 871 Bytes
/
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
var common = require('./lib/common');
module.exports = {
common: common,
BaseDeflate: require('./lib/BaseDeflate'),
Deflate: require('./lib/Deflate'),
DeflateStream: require('./lib/DeflateStream'),
BaseInflate: require('./lib/BaseInflate'),
Inflate: require('./lib/Inflate')
};
common.assign(
module.exports,
require('./lib/def'),
require('./lib/inf'),
require('./lib/nodeDeflateStream'),
require('./lib/nodeInflateStream')
);
function wrapForNode(fn) {
return function(src) {
var uint8 = fn.apply(null, arguments);
return Buffer.isBuffer(src) ? new Buffer(uint8.buffer, uint8.byteOffset, uint8.byteOffset + uint8.length) : uint8;
};
}
if (typeof process === 'object') {
[
'deflate',
'rawDeflate',
'inflate',
'rawInflate'
].forEach(function(name) { module.exports[name] = wrapForNode(module.exports[name]) });
};