source: trip-planner-front/node_modules/lodash/_cloneBuffer.js@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.0 KB
Line 
1var root = require('./_root');
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
35module.exports = cloneBuffer;
Note: See TracBrowser for help on using the repository browser.