Skip to content

Commit

Permalink
Improve utils.clone() method
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Apr 11, 2017
1 parent 7ffb98a commit c5d96f3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/Room.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class Room extends EventEmitter
}
else if (codec.kind === '')
{
let clonedCodec = utils.cloneObject(codec);
let clonedCodec = utils.clone(codec);

clonedCodec.kind = kind;
kindCapabilities.codecs.push(clonedCodec);
Expand All @@ -281,7 +281,7 @@ class Room extends EventEmitter
}
else if (headerExtension.kind === '')
{
let clonedHeaderExtension = utils.cloneObject(headerExtension);
let clonedHeaderExtension = utils.clone(headerExtension);

clonedHeaderExtension.kind = kind;
kindCapabilities.headerExtensions.push(clonedHeaderExtension);
Expand Down
2 changes: 1 addition & 1 deletion lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Server extends EventEmitter
this._closed = false;

// Clone options.
options = utils.cloneObject(options);
options = utils.clone(options);

// Update numWorkers (if given).
if (check.integer(options.numWorkers) && check.positive(options.numWorkers))
Expand Down
4 changes: 2 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ module.exports =

randomNumber: randomNumberGenerator,

cloneObject(obj)
clone(obj)
{
if (!obj || typeof obj !== 'object' || Array.isArray(obj))
if (!obj || typeof obj !== 'object')
return {};
else
return clone(obj, false);
Expand Down

0 comments on commit c5d96f3

Please sign in to comment.