mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
435 B
21 lines
435 B
9 years ago
|
/**
|
||
|
* Creates a clone of `buffer`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Buffer} buffer The buffer to clone.
|
||
|
* @param {boolean} [isDeep] Specify a deep clone.
|
||
|
* @returns {Buffer} Returns the cloned buffer.
|
||
|
*/
|
||
|
function cloneBuffer(buffer, isDeep) {
|
||
|
if (isDeep) {
|
||
|
return buffer.slice();
|
||
|
}
|
||
|
var Ctor = buffer.constructor,
|
||
|
result = new Ctor(buffer.length);
|
||
|
|
||
|
buffer.copy(result);
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
module.exports = cloneBuffer;
|