main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[d565449] | 1 | import root from './_root.js';
|
---|
| 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 | export default cloneBuffer;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.