Skip to content

Commit

Permalink
Merge pull request #90 from ChALkeR/patch-1
Browse files Browse the repository at this point in the history
Avoid using deprecated Buffer constructor
  • Loading branch information
pvorb authored Mar 21, 2018
2 parents a321fd8 + 2d90739 commit e2a1a10
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@ function clone(parent, circular, depth, prototype, includeNonEnumerable) {
} else if (clone.__isDate(parent)) {
child = new Date(parent.getTime());
} else if (useBuffer && Buffer.isBuffer(parent)) {
child = new Buffer(parent.length);
if (Buffer.allocUnsafe) {
// Node.js >= 4.5.0
child = Buffer.allocUnsafe(parent.length);
} else {
// Older Node.js versions
child = new Buffer(parent.length);
}
parent.copy(child);
return child;
} else if (_instanceof(parent, Error)) {
Expand Down

0 comments on commit e2a1a10

Please sign in to comment.