Last change
on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[6a3a178] | 1 | var root = require('./_root');
|
---|
| 2 |
|
---|
| 3 | /** Detect free variable `exports`. */
|
---|
| 4 | var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
---|
| 5 |
|
---|
| 6 | /** Detect free variable `module`. */
|
---|
| 7 | var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
|
---|
| 8 |
|
---|
| 9 | /** Detect the popular CommonJS extension `module.exports`. */
|
---|
| 10 | var moduleExports = freeModule && freeModule.exports === freeExports;
|
---|
| 11 |
|
---|
| 12 | /** Built-in value references. */
|
---|
| 13 | var Buffer = moduleExports ? root.Buffer : undefined,
|
---|
| 14 | allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
|
---|
| 15 |
|
---|
| 16 | /**
|
---|
| 17 | * Creates a clone of `buffer`.
|
---|
| 18 | *
|
---|
| 19 | * @private
|
---|
| 20 | * @param {Buffer} buffer The buffer to clone.
|
---|
| 21 | * @param {boolean} [isDeep] Specify a deep clone.
|
---|
| 22 | * @returns {Buffer} Returns the cloned buffer.
|
---|
| 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;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.