mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Use Buffer.allocUnsafe when available.
This commit is contained in:
@@ -1470,6 +1470,7 @@
|
||||
var Buffer = moduleExports ? context.Buffer : undefined,
|
||||
Symbol = context.Symbol,
|
||||
Uint8Array = context.Uint8Array,
|
||||
allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
|
||||
defineProperty = Object.defineProperty,
|
||||
getPrototype = overArg(Object.getPrototypeOf, Object),
|
||||
iteratorSymbol = Symbol ? Symbol.iterator : undefined,
|
||||
@@ -4424,7 +4425,9 @@
|
||||
if (isDeep) {
|
||||
return buffer.slice();
|
||||
}
|
||||
var result = new buffer.constructor(buffer.length);
|
||||
var length = buffer.length,
|
||||
result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
|
||||
|
||||
buffer.copy(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user