source: imaps-frontend/node_modules/lodash-es/_cloneBuffer.js@ d565449

main
Last change on this file since d565449 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
RevLine 
[d565449]1import root from './_root.js';
2
3/** Detect free variable `exports`. */
4var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
5
6/** Detect free variable `module`. */
7var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
8
9/** Detect the popular CommonJS extension `module.exports`. */
10var moduleExports = freeModule && freeModule.exports === freeExports;
11
12/** Built-in value references. */
13var 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 */
24function 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
35export default cloneBuffer;
Note: See TracBrowser for help on using the repository browser.