1 | var root = require('./_root');
|
2 |
|
3 |
|
4 | var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
5 |
|
6 |
|
7 | var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
|
8 |
|
9 |
|
10 | var moduleExports = freeModule && freeModule.exports === freeExports;
|
11 |
|
12 |
|
13 | var Buffer = moduleExports ? root.Buffer : undefined,
|
14 | allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | function cloneBuffer(buffer, isDeep) {
|
25 | if (isDeep) {
|
26 | return buffer.slice();
|
27 | }
|
28 | var length = buffer.length,
|
29 | result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
|
30 |
|
31 | buffer.copy(result);
|
32 | return result;
|
33 | }
|
34 |
|
35 | module.exports = cloneBuffer;
|