不要怂,就是干,撸起袖子干!

Commit 3d316493 by Daniel Friesen

Fix code style.

1 parent eff36923
Showing with 11 additions and 3 deletions
......@@ -96,7 +96,15 @@ var Utils = module.exports = {
cloneDeep: function(obj, fn) {
return lodash.cloneDeep(obj, function (elem) {
// Preserve special data-types like `fn` across clones. _.get() is used for checking up the prototype chain
if (elem && !Array.isArray(elem) && !lodash.isPlainObject(elem) && typeof elem.clone === 'function') {return elem.clone(); }
if (elem) {
// Allow objects to implement their own clone method
if (typeof elem.clone === 'function') {
// However do not mistakenly call clone methods on arrays and plain objects
if (!Array.isArray(elem) && !lodash.isPlainObject(elem)) {
return elem.clone();
}
}
}
// Unfortunately, lodash.cloneDeep doesn't preserve Buffer.isBuffer, which we have to rely on for binary data
if (Buffer.isBuffer(elem)) { return elem; }
......
......@@ -111,8 +111,8 @@ describe(Support.getTestDialectTeaser('Utils'), function() {
describe('cloneDeep', function() {
it('should clone objects', function() {
var obj = {foo: 1},
clone = Utils.cloneDeep(obj);
var obj = {foo: 1}
, clone = Utils.cloneDeep(obj);
expect(obj).to.not.equal(clone);
});
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!