lodash.size
Advanced tools
Comparing version 4.0.6 to 4.1.0
351
index.js
/** | ||
* lodash 4.0.6 (Custom Build) <https://lodash.com/> | ||
* lodash (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
@@ -9,4 +9,2 @@ * Copyright jQuery Foundation and other contributors <https://jquery.org/> | ||
*/ | ||
var keys = require('lodash.keys'), | ||
root = require('lodash._root'); | ||
@@ -17,3 +15,4 @@ /** Used as references for various `Number` constants. */ | ||
/** `Object#toString` result references. */ | ||
var funcTag = '[object Function]', | ||
var argsTag = '[object Arguments]', | ||
funcTag = '[object Function]', | ||
genTag = '[object GeneratorFunction]', | ||
@@ -38,2 +37,5 @@ mapTag = '[object Map]', | ||
/** Used to detect unsigned integer values. */ | ||
var reIsUint = /^(?:0|[1-9]\d*)$/; | ||
/** Used to compose unicode character classes. */ | ||
@@ -68,3 +70,56 @@ var rsAstralRange = '\\ud800-\\udfff', | ||
/** Detect free variable `global` from Node.js. */ | ||
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; | ||
/** Detect free variable `self`. */ | ||
var freeSelf = typeof self == 'object' && self && self.Object === Object && self; | ||
/** Used as a reference to the global object. */ | ||
var root = freeGlobal || freeSelf || Function('return this')(); | ||
/** | ||
* The base implementation of `_.property` without support for deep paths. | ||
* | ||
* @private | ||
* @param {string} key The key of the property to get. | ||
* @returns {Function} Returns the new accessor function. | ||
*/ | ||
function baseProperty(key) { | ||
return function(object) { | ||
return object == null ? undefined : object[key]; | ||
}; | ||
} | ||
/** | ||
* The base implementation of `_.times` without support for iteratee shorthands | ||
* or max array length checks. | ||
* | ||
* @private | ||
* @param {number} n The number of times to invoke `iteratee`. | ||
* @param {Function} iteratee The function invoked per iteration. | ||
* @returns {Array} Returns the array of results. | ||
*/ | ||
function baseTimes(n, iteratee) { | ||
var index = -1, | ||
result = Array(n); | ||
while (++index < n) { | ||
result[index] = iteratee(index); | ||
} | ||
return result; | ||
} | ||
/** | ||
* Gets the value at `key` of `object`. | ||
* | ||
* @private | ||
* @param {Object} [object] The object to query. | ||
* @param {string} key The key of the property to get. | ||
* @returns {*} Returns the property value. | ||
*/ | ||
function getValue(object, key) { | ||
return object == null ? undefined : object[key]; | ||
} | ||
/** | ||
* Checks if `value` is a host object in IE < 9. | ||
@@ -89,2 +144,16 @@ * | ||
/** | ||
* Creates a function that invokes `func` with its first argument transformed. | ||
* | ||
* @private | ||
* @param {Function} func The function to wrap. | ||
* @param {Function} transform The argument transform. | ||
* @returns {Function} Returns the new function. | ||
*/ | ||
function overArg(func, transform) { | ||
return function(arg) { | ||
return func(transform(arg)); | ||
}; | ||
} | ||
/** | ||
* Gets the number of symbols in `string`. | ||
@@ -110,2 +179,11 @@ * | ||
/** Used to detect overreaching core-js shims. */ | ||
var coreJsData = root['__core-js_shared__']; | ||
/** Used to detect methods masquerading as native. */ | ||
var maskSrcKey = (function() { | ||
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); | ||
return uid ? ('Symbol(src)_1.' + uid) : ''; | ||
}()); | ||
/** Used to resolve the decompiled source of functions. */ | ||
@@ -130,2 +208,9 @@ var funcToString = Function.prototype.toString; | ||
/** Built-in value references. */ | ||
var propertyIsEnumerable = objectProto.propertyIsEnumerable; | ||
/* Built-in method references for those with the same name as other `lodash` methods. */ | ||
var nativeGetPrototype = Object.getPrototypeOf, | ||
nativeKeys = Object.keys; | ||
/* Built-in method references that are verified to be native. */ | ||
@@ -146,15 +231,56 @@ var DataView = getNative(root, 'DataView'), | ||
/** | ||
* The base implementation of `_.property` without support for deep paths. | ||
* The base implementation of `getTag`. | ||
* | ||
* @private | ||
* @param {string} key The key of the property to get. | ||
* @returns {Function} Returns the new function. | ||
* @param {*} value The value to query. | ||
* @returns {string} Returns the `toStringTag`. | ||
*/ | ||
function baseProperty(key) { | ||
return function(object) { | ||
return object == null ? undefined : object[key]; | ||
}; | ||
function baseGetTag(value) { | ||
return objectToString.call(value); | ||
} | ||
/** | ||
* The base implementation of `_.has` without support for deep paths. | ||
* | ||
* @private | ||
* @param {Object} [object] The object to query. | ||
* @param {Array|string} key The key to check. | ||
* @returns {boolean} Returns `true` if `key` exists, else `false`. | ||
*/ | ||
function baseHas(object, key) { | ||
// Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`, | ||
// that are composed entirely of index properties, return `false` for | ||
// `hasOwnProperty` checks of them. | ||
return object != null && | ||
(hasOwnProperty.call(object, key) || | ||
(typeof object == 'object' && key in object && getPrototype(object) === null)); | ||
} | ||
/** | ||
* The base implementation of `_.isNative` without bad shim checks. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a native function, | ||
* else `false`. | ||
*/ | ||
function baseIsNative(value) { | ||
if (!isObject(value) || isMasked(value)) { | ||
return false; | ||
} | ||
var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor; | ||
return pattern.test(toSource(value)); | ||
} | ||
/** | ||
* The base implementation of `_.keys` which doesn't skip the constructor | ||
* property of prototypes or treat sparse arrays as dense. | ||
* | ||
* @private | ||
* @param {Object} object The object to query. | ||
* @returns {Array} Returns the array of property names. | ||
*/ | ||
var baseKeys = overArg(nativeKeys, Object); | ||
/** | ||
* Gets the "length" property value of `object`. | ||
@@ -181,7 +307,16 @@ * | ||
function getNative(object, key) { | ||
var value = object[key]; | ||
return isNative(value) ? value : undefined; | ||
var value = getValue(object, key); | ||
return baseIsNative(value) ? value : undefined; | ||
} | ||
/** | ||
* Gets the `[[Prototype]]` of `value`. | ||
* | ||
* @private | ||
* @param {*} value The value to query. | ||
* @returns {null|Object} Returns the `[[Prototype]]`. | ||
*/ | ||
var getPrototype = overArg(nativeGetPrototype, Object); | ||
/** | ||
* Gets the `toStringTag` of `value`. | ||
@@ -193,5 +328,3 @@ * | ||
*/ | ||
function getTag(value) { | ||
return objectToString.call(value); | ||
} | ||
var getTag = baseGetTag; | ||
@@ -224,2 +357,59 @@ // Fallback for data views, maps, sets, and weak maps in IE 11, | ||
/** | ||
* Creates an array of index keys for `object` values of arrays, | ||
* `arguments` objects, and strings, otherwise `null` is returned. | ||
* | ||
* @private | ||
* @param {Object} object The object to query. | ||
* @returns {Array|null} Returns index keys, else `null`. | ||
*/ | ||
function indexKeys(object) { | ||
var length = object ? object.length : undefined; | ||
if (isLength(length) && | ||
(isArray(object) || isString(object) || isArguments(object))) { | ||
return baseTimes(length, String); | ||
} | ||
return null; | ||
} | ||
/** | ||
* Checks if `value` is a valid array-like index. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. | ||
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`. | ||
*/ | ||
function isIndex(value, length) { | ||
length = length == null ? MAX_SAFE_INTEGER : length; | ||
return !!length && | ||
(typeof value == 'number' || reIsUint.test(value)) && | ||
(value > -1 && value % 1 == 0 && value < length); | ||
} | ||
/** | ||
* Checks if `func` has its source masked. | ||
* | ||
* @private | ||
* @param {Function} func The function to check. | ||
* @returns {boolean} Returns `true` if `func` is masked, else `false`. | ||
*/ | ||
function isMasked(func) { | ||
return !!maskSrcKey && (maskSrcKey in func); | ||
} | ||
/** | ||
* Checks if `value` is likely a prototype object. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`. | ||
*/ | ||
function isPrototype(value) { | ||
var Ctor = value && value.constructor, | ||
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; | ||
return value === proto; | ||
} | ||
/** | ||
* Converts `func` to its source code. | ||
@@ -282,3 +472,3 @@ * | ||
/** | ||
* Checks if `value` is classified as an `Array` object. | ||
* Checks if `value` is likely an `arguments` object. | ||
* | ||
@@ -288,9 +478,31 @@ * @static | ||
* @since 0.1.0 | ||
* @type {Function} | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is correctly classified, | ||
* @returns {boolean} Returns `true` if `value` is an `arguments` object, | ||
* else `false`. | ||
* @example | ||
* | ||
* _.isArguments(function() { return arguments; }()); | ||
* // => true | ||
* | ||
* _.isArguments([1, 2, 3]); | ||
* // => false | ||
*/ | ||
function isArguments(value) { | ||
// Safari 8.1 incorrectly makes `arguments.callee` enumerable in strict mode. | ||
return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') && | ||
(!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag); | ||
} | ||
/** | ||
* Checks if `value` is classified as an `Array` object. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 0.1.0 | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is an array, else `false`. | ||
* @example | ||
* | ||
* _.isArray([1, 2, 3]); | ||
@@ -340,2 +552,31 @@ * // => true | ||
/** | ||
* This method is like `_.isArrayLike` except that it also checks if `value` | ||
* is an object. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is an array-like object, | ||
* else `false`. | ||
* @example | ||
* | ||
* _.isArrayLikeObject([1, 2, 3]); | ||
* // => true | ||
* | ||
* _.isArrayLikeObject(document.body.children); | ||
* // => true | ||
* | ||
* _.isArrayLikeObject('abc'); | ||
* // => false | ||
* | ||
* _.isArrayLikeObject(_.noop); | ||
* // => false | ||
*/ | ||
function isArrayLikeObject(value) { | ||
return isObjectLike(value) && isArrayLike(value); | ||
} | ||
/** | ||
* Checks if `value` is classified as a `Function` object. | ||
@@ -348,4 +589,3 @@ * | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is correctly classified, | ||
* else `false`. | ||
* @returns {boolean} Returns `true` if `value` is a function, else `false`. | ||
* @example | ||
@@ -458,50 +698,71 @@ * | ||
/** | ||
* Checks if `value` is a native function. | ||
* Checks if `value` is classified as a `String` primitive or object. | ||
* | ||
* @static | ||
* @since 0.1.0 | ||
* @memberOf _ | ||
* @since 3.0.0 | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a native function, | ||
* else `false`. | ||
* @returns {boolean} Returns `true` if `value` is a string, else `false`. | ||
* @example | ||
* | ||
* _.isNative(Array.prototype.push); | ||
* _.isString('abc'); | ||
* // => true | ||
* | ||
* _.isNative(_); | ||
* _.isString(1); | ||
* // => false | ||
*/ | ||
function isNative(value) { | ||
if (!isObject(value)) { | ||
return false; | ||
} | ||
var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor; | ||
return pattern.test(toSource(value)); | ||
function isString(value) { | ||
return typeof value == 'string' || | ||
(!isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag); | ||
} | ||
/** | ||
* Checks if `value` is classified as a `String` primitive or object. | ||
* Creates an array of the own enumerable property names of `object`. | ||
* | ||
* **Note:** Non-object values are coerced to objects. See the | ||
* [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys) | ||
* for more details. | ||
* | ||
* @static | ||
* @since 0.1.0 | ||
* @memberOf _ | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is correctly classified, | ||
* else `false`. | ||
* @category Object | ||
* @param {Object} object The object to query. | ||
* @returns {Array} Returns the array of property names. | ||
* @example | ||
* | ||
* _.isString('abc'); | ||
* // => true | ||
* function Foo() { | ||
* this.a = 1; | ||
* this.b = 2; | ||
* } | ||
* | ||
* _.isString(1); | ||
* // => false | ||
* Foo.prototype.c = 3; | ||
* | ||
* _.keys(new Foo); | ||
* // => ['a', 'b'] (iteration order is not guaranteed) | ||
* | ||
* _.keys('hi'); | ||
* // => ['0', '1'] | ||
*/ | ||
function isString(value) { | ||
return typeof value == 'string' || | ||
(!isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag); | ||
function keys(object) { | ||
var isProto = isPrototype(object); | ||
if (!(isProto || isArrayLike(object))) { | ||
return baseKeys(object); | ||
} | ||
var indexes = indexKeys(object), | ||
skipIndexes = !!indexes, | ||
result = indexes || [], | ||
length = result.length; | ||
for (var key in object) { | ||
if (baseHas(object, key) && | ||
!(skipIndexes && (key == 'length' || isIndex(key, length))) && | ||
!(isProto && key == 'constructor')) { | ||
result.push(key); | ||
} | ||
} | ||
return result; | ||
} | ||
module.exports = size; |
{ | ||
"name": "lodash.size", | ||
"version": "4.0.6", | ||
"version": "4.1.0", | ||
"description": "The lodash method `_.size` exported as a module.", | ||
@@ -16,7 +16,3 @@ "homepage": "https://lodash.com/", | ||
"repository": "lodash/lodash", | ||
"scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" }, | ||
"dependencies": { | ||
"lodash._root": "~3.0.0", | ||
"lodash.keys": "^4.0.0" | ||
} | ||
"scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" } | ||
} |
@@ -1,2 +0,2 @@ | ||
# lodash.size v4.0.6 | ||
# lodash.size v4.1.0 | ||
@@ -18,2 +18,2 @@ The [lodash](https://lodash.com/) method `_.size` exported as a [Node.js](https://nodejs.org/) module. | ||
See the [documentation](https://lodash.com/docs#size) or [package source](https://github.com/lodash/lodash/blob/4.0.6-npm-packages/lodash.size) for more details. | ||
See the [documentation](https://lodash.com/docs#size) or [package source](https://github.com/lodash/lodash/blob/4.1.0-npm-packages/lodash.size) for more details. |
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
23714
0
691
- Removedlodash._root@~3.0.0
- Removedlodash.keys@^4.0.0
- Removedlodash._root@3.0.1(transitive)
- Removedlodash.keys@4.2.0(transitive)