lodash.xorby
Advanced tools
Comparing version 4.1.1 to 4.2.0
580
index.js
/** | ||
* lodash 4.1.1 (Custom Build) <https://lodash.com/> | ||
* lodash 4.2.0 (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
@@ -9,24 +9,6 @@ * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/> | ||
*/ | ||
var SetCache = require('lodash._setcache'), | ||
arrayFilter = require('lodash._arrayfilter'), | ||
arrayIncludes = require('lodash._arrayincludes'), | ||
arrayIncludesWith = require('lodash._arrayincludeswith'), | ||
arrayMap = require('lodash._arraymap'), | ||
baseIsEqual = require('lodash._baseisequal'), | ||
baseIsMatch = require('lodash._baseismatch'), | ||
cacheHas = require('lodash._cachehas'), | ||
get = require('lodash.get'), | ||
hasIn = require('lodash.hasin'), | ||
rest = require('lodash.rest'), | ||
root = require('lodash._root'), | ||
toPairs = require('lodash.topairs'), | ||
toString = require('lodash.tostring'); | ||
var baseIteratee = require('lodash._baseiteratee'), | ||
baseXor = require('lodash._basexor'), | ||
rest = require('lodash.rest'); | ||
/** Used to compose bitmasks for comparison styles. */ | ||
var UNORDERED_COMPARE_FLAG = 1, | ||
PARTIAL_COMPARE_FLAG = 2; | ||
/** Used as the size to enable large array optimizations. */ | ||
var LARGE_ARRAY_SIZE = 200; | ||
/** Used as references for various `Number` constants. */ | ||
@@ -39,93 +21,29 @@ var MAX_SAFE_INTEGER = 9007199254740991; | ||
/** Used to match property names within property paths. */ | ||
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, | ||
reIsPlainProp = /^\w*$/, | ||
rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]/g; | ||
/** Used to match `RegExp` [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns). */ | ||
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; | ||
/** Used to match backslashes in property paths. */ | ||
var reEscapeChar = /\\(\\)?/g; | ||
/** Used to detect host constructors (Safari > 5). */ | ||
var reIsHostCtor = /^\[object .+?Constructor\]$/; | ||
/** | ||
* Appends the elements of `values` to `array`. | ||
* A specialized version of `_.filter` for arrays without support for | ||
* iteratee shorthands. | ||
* | ||
* @private | ||
* @param {Array} array The array to modify. | ||
* @param {Array} values The values to append. | ||
* @returns {Array} Returns `array`. | ||
* @param {Array} array The array to iterate over. | ||
* @param {Function} predicate The function invoked per iteration. | ||
* @returns {Array} Returns the new filtered array. | ||
*/ | ||
function arrayPush(array, values) { | ||
function arrayFilter(array, predicate) { | ||
var index = -1, | ||
length = values.length, | ||
offset = array.length; | ||
length = array.length, | ||
resIndex = -1, | ||
result = []; | ||
while (++index < length) { | ||
array[offset + index] = values[index]; | ||
var value = array[index]; | ||
if (predicate(value, index, array)) { | ||
result[++resIndex] = value; | ||
} | ||
} | ||
return array; | ||
} | ||
/** | ||
* The base implementation of `_.unary` without support for storing wrapper metadata. | ||
* | ||
* @private | ||
* @param {Function} func The function to cap arguments for. | ||
* @returns {Function} Returns the new function. | ||
*/ | ||
function baseUnary(func) { | ||
return function(value) { | ||
return func(value); | ||
}; | ||
} | ||
/** | ||
* Checks if `value` is a host object in IE < 9. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a host object, else `false`. | ||
*/ | ||
function isHostObject(value) { | ||
// Many host objects are `Object` objects that can coerce to strings | ||
// despite having improperly defined `toString` methods. | ||
var result = false; | ||
if (value != null && typeof value.toString != 'function') { | ||
try { | ||
result = !!(value + ''); | ||
} catch (e) {} | ||
} | ||
return result; | ||
} | ||
/** | ||
* Converts `set` to an array. | ||
* | ||
* @private | ||
* @param {Object} set The set to convert. | ||
* @returns {Array} Returns the converted array. | ||
*/ | ||
function setToArray(set) { | ||
var index = -1, | ||
result = Array(set.size); | ||
set.forEach(function(value) { | ||
result[++index] = value; | ||
}); | ||
return result; | ||
} | ||
/** Used for built-in method references. */ | ||
var objectProto = Object.prototype; | ||
/** Used to resolve the decompiled source of functions. */ | ||
var funcToString = Function.prototype.toString; | ||
/** Used to check objects for own properties. */ | ||
var hasOwnProperty = objectProto.hasOwnProperty; | ||
/** | ||
@@ -137,153 +55,3 @@ * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
/** Used to detect if a method is native. */ | ||
var reIsNative = RegExp('^' + | ||
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') | ||
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' | ||
); | ||
/* Built-in method references that are verified to be native. */ | ||
var Set = getNative(root, 'Set'); | ||
/** | ||
* The base implementation of methods like `_.difference` without support for | ||
* excluding multiple arrays or iteratee shorthands. | ||
* | ||
* @private | ||
* @param {Array} array The array to inspect. | ||
* @param {Array} values The values to exclude. | ||
* @param {Function} [iteratee] The iteratee invoked per element. | ||
* @param {Function} [comparator] The comparator invoked per element. | ||
* @returns {Array} Returns the new array of filtered values. | ||
*/ | ||
function baseDifference(array, values, iteratee, comparator) { | ||
var index = -1, | ||
includes = arrayIncludes, | ||
isCommon = true, | ||
length = array.length, | ||
result = [], | ||
valuesLength = values.length; | ||
if (!length) { | ||
return result; | ||
} | ||
if (iteratee) { | ||
values = arrayMap(values, baseUnary(iteratee)); | ||
} | ||
if (comparator) { | ||
includes = arrayIncludesWith; | ||
isCommon = false; | ||
} | ||
else if (values.length >= LARGE_ARRAY_SIZE) { | ||
includes = cacheHas; | ||
isCommon = false; | ||
values = new SetCache(values); | ||
} | ||
outer: | ||
while (++index < length) { | ||
var value = array[index], | ||
computed = iteratee ? iteratee(value) : value; | ||
if (isCommon && computed === computed) { | ||
var valuesIndex = valuesLength; | ||
while (valuesIndex--) { | ||
if (values[valuesIndex] === computed) { | ||
continue outer; | ||
} | ||
} | ||
result.push(value); | ||
} | ||
else if (!includes(values, computed, comparator)) { | ||
result.push(value); | ||
} | ||
} | ||
return result; | ||
} | ||
/** | ||
* The base implementation of `_.get` without support for default values. | ||
* | ||
* @private | ||
* @param {Object} object The object to query. | ||
* @param {Array|string} path The path of the property to get. | ||
* @returns {*} Returns the resolved value. | ||
*/ | ||
function baseGet(object, path) { | ||
path = isKey(path, object) ? [path + ''] : baseToPath(path); | ||
var index = 0, | ||
length = path.length; | ||
while (object != null && index < length) { | ||
object = object[path[index++]]; | ||
} | ||
return (index && index == length) ? object : undefined; | ||
} | ||
/** | ||
* The base implementation of `_.iteratee`. | ||
* | ||
* @private | ||
* @param {*} [value=_.identity] The value to convert to an iteratee. | ||
* @returns {Function} Returns the iteratee. | ||
*/ | ||
function baseIteratee(value) { | ||
var type = typeof value; | ||
if (type == 'function') { | ||
return value; | ||
} | ||
if (value == null) { | ||
return identity; | ||
} | ||
if (type == 'object') { | ||
return isArray(value) | ||
? baseMatchesProperty(value[0], value[1]) | ||
: baseMatches(value); | ||
} | ||
return property(value); | ||
} | ||
/** | ||
* The base implementation of `_.matches` which doesn't clone `source`. | ||
* | ||
* @private | ||
* @param {Object} source The object of property values to match. | ||
* @returns {Function} Returns the new function. | ||
*/ | ||
function baseMatches(source) { | ||
var matchData = getMatchData(source); | ||
if (matchData.length == 1 && matchData[0][2]) { | ||
var key = matchData[0][0], | ||
value = matchData[0][1]; | ||
return function(object) { | ||
if (object == null) { | ||
return false; | ||
} | ||
return object[key] === value && | ||
(value !== undefined || (key in Object(object))); | ||
}; | ||
} | ||
return function(object) { | ||
return object === source || baseIsMatch(object, source, matchData); | ||
}; | ||
} | ||
/** | ||
* The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. | ||
* | ||
* @private | ||
* @param {string} path The path of the property to get. | ||
* @param {*} srcValue The value to match. | ||
* @returns {Function} Returns the new function. | ||
*/ | ||
function baseMatchesProperty(path, srcValue) { | ||
return function(object) { | ||
var objValue = get(object, path); | ||
return (objValue === undefined && objValue === srcValue) | ||
? hasIn(object, path) | ||
: baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG); | ||
}; | ||
} | ||
/** | ||
* The base implementation of `_.property` without support for deep paths. | ||
@@ -302,123 +70,2 @@ * | ||
/** | ||
* A specialized version of `baseProperty` which supports deep paths. | ||
* | ||
* @private | ||
* @param {Array|string} path The path of the property to get. | ||
* @returns {Function} Returns the new function. | ||
*/ | ||
function basePropertyDeep(path) { | ||
return function(object) { | ||
return baseGet(object, path); | ||
}; | ||
} | ||
/** | ||
* The base implementation of `_.toPath` which only converts `value` to a | ||
* path if it's not one. | ||
* | ||
* @private | ||
* @param {*} value The value to process. | ||
* @returns {Array} Returns the property path array. | ||
*/ | ||
function baseToPath(value) { | ||
return isArray(value) ? value : stringToPath(value); | ||
} | ||
/** | ||
* The base implementation of `_.uniqBy` without support for iteratee shorthands. | ||
* | ||
* @private | ||
* @param {Array} array The array to inspect. | ||
* @param {Function} [iteratee] The iteratee invoked per element. | ||
* @param {Function} [comparator] The comparator invoked per element. | ||
* @returns {Array} Returns the new duplicate free array. | ||
*/ | ||
function baseUniq(array, iteratee, comparator) { | ||
var index = -1, | ||
includes = arrayIncludes, | ||
length = array.length, | ||
isCommon = true, | ||
result = [], | ||
seen = result; | ||
if (comparator) { | ||
isCommon = false; | ||
includes = arrayIncludesWith; | ||
} | ||
else if (length >= LARGE_ARRAY_SIZE) { | ||
var set = iteratee ? null : createSet(array); | ||
if (set) { | ||
return setToArray(set); | ||
} | ||
isCommon = false; | ||
includes = cacheHas; | ||
seen = new SetCache; | ||
} | ||
else { | ||
seen = iteratee ? [] : result; | ||
} | ||
outer: | ||
while (++index < length) { | ||
var value = array[index], | ||
computed = iteratee ? iteratee(value) : value; | ||
if (isCommon && computed === computed) { | ||
var seenIndex = seen.length; | ||
while (seenIndex--) { | ||
if (seen[seenIndex] === computed) { | ||
continue outer; | ||
} | ||
} | ||
if (iteratee) { | ||
seen.push(computed); | ||
} | ||
result.push(value); | ||
} | ||
else if (!includes(seen, computed, comparator)) { | ||
if (seen !== result) { | ||
seen.push(computed); | ||
} | ||
result.push(value); | ||
} | ||
} | ||
return result; | ||
} | ||
/** | ||
* The base implementation of methods like `_.xor`, without support for | ||
* iteratee shorthands, that accepts an array of arrays to inspect. | ||
* | ||
* @private | ||
* @param {Array} arrays The arrays to inspect. | ||
* @param {Function} [iteratee] The iteratee invoked per element. | ||
* @param {Function} [comparator] The comparator invoked per element. | ||
* @returns {Array} Returns the new array of values. | ||
*/ | ||
function baseXor(arrays, iteratee, comparator) { | ||
var index = -1, | ||
length = arrays.length; | ||
while (++index < length) { | ||
var result = result | ||
? arrayPush( | ||
baseDifference(result, arrays[index], iteratee, comparator), | ||
baseDifference(arrays[index], result, iteratee, comparator) | ||
) | ||
: arrays[index]; | ||
} | ||
return (result && result.length) ? baseUniq(result, iteratee, comparator) : []; | ||
} | ||
/** | ||
* Creates a set of `values`. | ||
* | ||
* @private | ||
* @param {Array} values The values to add to the set. | ||
* @returns {Object} Returns the new set. | ||
*/ | ||
var createSet = !(Set && new Set([1, 2]).size === 2) ? noop : function(values) { | ||
return new Set(values); | ||
}; | ||
/** | ||
* Gets the "length" property value of `object`. | ||
@@ -436,76 +83,2 @@ * | ||
/** | ||
* Gets the property names, values, and compare flags of `object`. | ||
* | ||
* @private | ||
* @param {Object} object The object to query. | ||
* @returns {Array} Returns the match data of `object`. | ||
*/ | ||
function getMatchData(object) { | ||
var result = toPairs(object), | ||
length = result.length; | ||
while (length--) { | ||
result[length][2] = isStrictComparable(result[length][1]); | ||
} | ||
return result; | ||
} | ||
/** | ||
* Gets the native function at `key` of `object`. | ||
* | ||
* @private | ||
* @param {Object} object The object to query. | ||
* @param {string} key The key of the method to get. | ||
* @returns {*} Returns the function if it's native, else `undefined`. | ||
*/ | ||
function getNative(object, key) { | ||
var value = object == null ? undefined : object[key]; | ||
return isNative(value) ? value : undefined; | ||
} | ||
/** | ||
* Checks if `value` is a property name and not a property path. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @param {Object} [object] The object to query keys on. | ||
* @returns {boolean} Returns `true` if `value` is a property name, else `false`. | ||
*/ | ||
function isKey(value, object) { | ||
if (typeof value == 'number') { | ||
return true; | ||
} | ||
return !isArray(value) && | ||
(reIsPlainProp.test(value) || !reIsDeepProp.test(value) || | ||
(object != null && value in Object(object))); | ||
} | ||
/** | ||
* Checks if `value` is suitable for strict equality comparisons, i.e. `===`. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` if suitable for strict | ||
* equality comparisons, else `false`. | ||
*/ | ||
function isStrictComparable(value) { | ||
return value === value && !isObject(value); | ||
} | ||
/** | ||
* Converts `string` to a property path array. | ||
* | ||
* @private | ||
* @param {string} string The string to convert. | ||
* @returns {Array} Returns the property path array. | ||
*/ | ||
function stringToPath(string) { | ||
var result = []; | ||
toString(string).replace(rePropName, function(match, number, quote, string) { | ||
result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match)); | ||
}); | ||
return result; | ||
} | ||
/** | ||
* Gets the last element of `array`. | ||
@@ -557,27 +130,2 @@ * | ||
/** | ||
* Checks if `value` is classified as an `Array` object. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @type Function | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. | ||
* @example | ||
* | ||
* _.isArray([1, 2, 3]); | ||
* // => true | ||
* | ||
* _.isArray(document.body.children); | ||
* // => false | ||
* | ||
* _.isArray('abc'); | ||
* // => false | ||
* | ||
* _.isArray(_.noop); | ||
* // => false | ||
*/ | ||
var isArray = Array.isArray; | ||
/** | ||
* Checks if `value` is array-like. A value is considered array-like if it's | ||
@@ -589,3 +137,2 @@ * not a function and has a `value.length` that's an integer greater than or | ||
* @memberOf _ | ||
* @type Function | ||
* @category Lang | ||
@@ -619,3 +166,2 @@ * @param {*} value The value to check. | ||
* @memberOf _ | ||
* @type Function | ||
* @category Lang | ||
@@ -691,3 +237,4 @@ * @param {*} value The value to check. | ||
function isLength(value) { | ||
return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; | ||
return typeof value == 'number' && | ||
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; | ||
} | ||
@@ -750,91 +297,2 @@ | ||
/** | ||
* Checks if `value` is a native function. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a native function, else `false`. | ||
* @example | ||
* | ||
* _.isNative(Array.prototype.push); | ||
* // => true | ||
* | ||
* _.isNative(_); | ||
* // => false | ||
*/ | ||
function isNative(value) { | ||
if (value == null) { | ||
return false; | ||
} | ||
if (isFunction(value)) { | ||
return reIsNative.test(funcToString.call(value)); | ||
} | ||
return isObjectLike(value) && | ||
(isHostObject(value) ? reIsNative : reIsHostCtor).test(value); | ||
} | ||
/** | ||
* This method returns the first argument given to it. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Util | ||
* @param {*} value Any value. | ||
* @returns {*} Returns `value`. | ||
* @example | ||
* | ||
* var object = { 'user': 'fred' }; | ||
* | ||
* _.identity(object) === object; | ||
* // => true | ||
*/ | ||
function identity(value) { | ||
return value; | ||
} | ||
/** | ||
* A no-operation function that returns `undefined` regardless of the | ||
* arguments it receives. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Util | ||
* @example | ||
* | ||
* var object = { 'user': 'fred' }; | ||
* | ||
* _.noop(object) === undefined; | ||
* // => true | ||
*/ | ||
function noop() { | ||
// No operation performed. | ||
} | ||
/** | ||
* Creates a function that returns the value at `path` of a given object. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Util | ||
* @param {Array|string} path The path of the property to get. | ||
* @returns {Function} Returns the new function. | ||
* @example | ||
* | ||
* var objects = [ | ||
* { 'a': { 'b': { 'c': 2 } } }, | ||
* { 'a': { 'b': { 'c': 1 } } } | ||
* ]; | ||
* | ||
* _.map(objects, _.property('a.b.c')); | ||
* // => [2, 1] | ||
* | ||
* _.map(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c'); | ||
* // => [1, 2] | ||
*/ | ||
function property(path) { | ||
return isKey(path) ? baseProperty(path) : basePropertyDeep(path); | ||
} | ||
module.exports = xorBy; |
{ | ||
"name": "lodash.xorby", | ||
"version": "4.1.1", | ||
"version": "4.2.0", | ||
"description": "The lodash method `_.xorBy` exported as a module.", | ||
@@ -18,17 +18,6 @@ "homepage": "https://lodash.com/", | ||
"dependencies": { | ||
"lodash._arrayfilter": "^3.0.0", | ||
"lodash._arrayincludes": "^4.0.0", | ||
"lodash._arrayincludeswith": "^4.0.0", | ||
"lodash._arraymap": "^3.0.0", | ||
"lodash._baseisequal": "^4.0.0", | ||
"lodash._baseismatch": "^4.0.0", | ||
"lodash._cachehas": "^4.0.0", | ||
"lodash._root": "^3.0.0", | ||
"lodash._setcache": "^4.0.0", | ||
"lodash.get": "^4.0.0", | ||
"lodash.hasin": "^4.0.0", | ||
"lodash.rest": "^4.0.0", | ||
"lodash.topairs": "^4.0.0", | ||
"lodash.tostring": "^4.0.0" | ||
"lodash._baseiteratee": "^4.0.0", | ||
"lodash._basexor": "^4.0.0", | ||
"lodash.rest": "^4.0.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# lodash.xorby v4.1.1 | ||
# lodash.xorby v4.2.0 | ||
@@ -18,2 +18,2 @@ The [lodash](https://lodash.com/) method `_.xorBy` exported as a [Node.js](https://nodejs.org/) module. | ||
See the [documentation](https://lodash.com/docs#xorBy) or [package source](https://github.com/lodash/lodash/blob/4.1.1-npm-packages/lodash.xorby) for more details. | ||
See the [documentation](https://lodash.com/docs#xorBy) or [package source](https://github.com/lodash/lodash/blob/4.2.0-npm-packages/lodash.xorby) for more details. |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
3
10008
271
1
+ Addedlodash._baseiteratee@^4.0.0
+ Addedlodash._basexor@^4.0.0
+ Addedlodash._basedifference@4.5.0(transitive)
+ Addedlodash._baseiteratee@4.7.0(transitive)
+ Addedlodash._basetostring@4.12.0(transitive)
+ Addedlodash._baseuniq@4.6.0(transitive)
+ Addedlodash._basexor@4.5.0(transitive)
+ Addedlodash._createset@4.0.3(transitive)
+ Addedlodash._stringtopath@4.8.0(transitive)
- Removedlodash._arrayfilter@^3.0.0
- Removedlodash._arrayincludes@^4.0.0
- Removedlodash._arrayincludeswith@^4.0.0
- Removedlodash._arraymap@^3.0.0
- Removedlodash._baseisequal@^4.0.0
- Removedlodash._baseismatch@^4.0.0
- Removedlodash._cachehas@^4.0.0
- Removedlodash._root@^3.0.0
- Removedlodash._setcache@^4.0.0
- Removedlodash.get@^4.0.0
- Removedlodash.hasin@^4.0.0
- Removedlodash.topairs@^4.0.0
- Removedlodash.tostring@^4.0.0
- Removedlodash._arrayfilter@3.0.0(transitive)
- Removedlodash._arrayincludes@4.0.0(transitive)
- Removedlodash._arrayincludeswith@4.0.0(transitive)
- Removedlodash._arraymap@3.0.0(transitive)
- Removedlodash._baseisequal@4.1.1(transitive)
- Removedlodash._baseismatch@4.0.2(transitive)
- Removedlodash._cachehas@4.0.0(transitive)
- Removedlodash._setcache@4.1.3(transitive)
- Removedlodash._stack@4.1.3(transitive)
- Removedlodash.get@4.4.2(transitive)
- Removedlodash.hasin@4.5.2(transitive)
- Removedlodash.keys@4.2.0(transitive)
- Removedlodash.topairs@4.3.0(transitive)
- Removedlodash.tostring@4.1.4(transitive)