lodash.clonedeepwith
Advanced tools
Comparing version 4.1.0 to 4.1.1
64
index.js
/** | ||
* lodash 4.1.0 (Custom Build) <https://lodash.com/> | ||
* lodash 4.1.1 (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
@@ -12,2 +12,3 @@ * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/> | ||
baseFor = require('lodash._basefor'), | ||
isBuffer = require('lodash.isbuffer'), | ||
keys = require('lodash.keys'), | ||
@@ -200,7 +201,9 @@ root = require('lodash._root'); | ||
var Map = getNative(root, 'Map'), | ||
Set = getNative(root, 'Set'); | ||
Set = getNative(root, 'Set'), | ||
WeakMap = getNative(root, 'WeakMap'); | ||
/** Used to detect maps and sets. */ | ||
/** Used to detect maps, sets, and weakmaps. */ | ||
var mapCtorString = Map ? funcToString.call(Map) : '', | ||
setCtorString = Set ? funcToString.call(Set) : ''; | ||
setCtorString = Set ? funcToString.call(Set) : '', | ||
weakMapCtorString = WeakMap ? funcToString.call(WeakMap) : ''; | ||
@@ -277,2 +280,5 @@ /** Used to convert symbols to primitives and strings. */ | ||
if (isBuffer(value)) { | ||
return cloneBuffer(value, isDeep); | ||
} | ||
if (tag == objectTag || tag == argsTag || (isFunc && !object)) { | ||
@@ -340,14 +346,33 @@ if (isHostObject(value)) { | ||
/** | ||
* Creates a clone of `buffer`. | ||
* Creates a clone of `buffer`. | ||
* | ||
* @private | ||
* @param {ArrayBuffer} buffer The array buffer to clone. | ||
* @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; | ||
} | ||
/** | ||
* Creates a clone of `arrayBuffer`. | ||
* | ||
* @private | ||
* @param {ArrayBuffer} arrayBuffer The array buffer to clone. | ||
* @returns {ArrayBuffer} Returns the cloned array buffer. | ||
*/ | ||
function cloneBuffer(buffer) { | ||
var Ctor = buffer.constructor, | ||
result = new Ctor(buffer.byteLength), | ||
function cloneArrayBuffer(arrayBuffer) { | ||
var Ctor = arrayBuffer.constructor, | ||
result = new Ctor(arrayBuffer.byteLength), | ||
view = new Uint8Array(result); | ||
view.set(new Uint8Array(buffer)); | ||
view.set(new Uint8Array(arrayBuffer)); | ||
return result; | ||
@@ -418,3 +443,3 @@ } | ||
return new Ctor(isDeep ? cloneBuffer(buffer) : buffer, typedArray.byteOffset, typedArray.length); | ||
return new Ctor(isDeep ? cloneArrayBuffer(buffer) : buffer, typedArray.byteOffset, typedArray.length); | ||
} | ||
@@ -527,4 +552,6 @@ | ||
// Fallback for IE 11 providing `toStringTag` values for maps and sets. | ||
if ((Map && getTag(new Map) != mapTag) || (Set && getTag(new Set) != setTag)) { | ||
// Fallback for IE 11 providing `toStringTag` values for maps, sets, and weakmaps. | ||
if ((Map && getTag(new Map) != mapTag) || | ||
(Set && getTag(new Set) != setTag) || | ||
(WeakMap && getTag(new WeakMap) != weakMapTag)) { | ||
getTag = function(value) { | ||
@@ -536,8 +563,7 @@ var result = objectToString.call(value), | ||
if (ctorString) { | ||
if (ctorString == mapCtorString) { | ||
return mapTag; | ||
switch (ctorString) { | ||
case mapCtorString: return mapTag; | ||
case setCtorString: return setTag; | ||
case weakMapCtorString: return weakMapTag; | ||
} | ||
if (ctorString == setCtorString) { | ||
return setTag; | ||
} | ||
} | ||
@@ -598,3 +624,3 @@ return result; | ||
case arrayBufferTag: | ||
return cloneBuffer(object); | ||
return cloneArrayBuffer(object); | ||
@@ -601,0 +627,0 @@ case boolTag: |
{ | ||
"name": "lodash.clonedeepwith", | ||
"version": "4.1.0", | ||
"version": "4.1.1", | ||
"description": "The lodash method `_.cloneDeepWith` exported as a module.", | ||
@@ -22,4 +22,5 @@ "homepage": "https://lodash.com/", | ||
"lodash._stack": "^4.0.0", | ||
"lodash.isbuffer": "^4.0.0", | ||
"lodash.keys": "^4.0.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# lodash.clonedeepwith v4.1.0 | ||
# lodash.clonedeepwith v4.1.1 | ||
@@ -18,2 +18,2 @@ The [lodash](https://lodash.com/) method `_.cloneDeepWith` exported as a [Node.js](https://nodejs.org/) module. | ||
See the [documentation](https://lodash.com/docs#cloneDeepWith) or [package source](https://github.com/lodash/lodash/blob/4.1.0-npm-packages/lodash.clonedeepwith) for more details. | ||
See the [documentation](https://lodash.com/docs#cloneDeepWith) or [package source](https://github.com/lodash/lodash/blob/4.1.1-npm-packages/lodash.clonedeepwith) for more details. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25788
779
6
+ Addedlodash.isbuffer@^4.0.0
+ Addedlodash.isbuffer@4.3.4(transitive)