lodash.isempty
Advanced tools
Comparing version 3.0.4 to 4.0.0
168
index.js
/** | ||
* lodash 3.0.4 (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modern modularize exports="npm" -o ./` | ||
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> | ||
* lodash 4.0.0 (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/> | ||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> | ||
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
* Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
* Available under MIT license <https://lodash.com/license> | ||
*/ | ||
var isArguments = require('lodash.isarguments'), | ||
isArray = require('lodash.isarray'), | ||
isFunction = require('lodash.isfunction'), | ||
isString = require('lodash.isstring'), | ||
keys = require('lodash.keys'); | ||
var keys = require('lodash.keys'), | ||
size = require('lodash.size'); | ||
/** | ||
* Checks if `value` is object-like. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is object-like, else `false`. | ||
*/ | ||
function isObjectLike(value) { | ||
return !!value && typeof value == 'object'; | ||
} | ||
/** `Object#toString` result references. */ | ||
var funcTag = '[object Function]', | ||
genTag = '[object GeneratorFunction]'; | ||
/** Used for built-in method references. */ | ||
var objectProto = global.Object.prototype; | ||
/** | ||
* Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer) | ||
* of an array-like value. | ||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
*/ | ||
var MAX_SAFE_INTEGER = 9007199254740991; | ||
var objectToString = objectProto.toString; | ||
/** | ||
* The base implementation of `_.property` without support for deep paths. | ||
* Checks if `value` is empty. A value is considered empty unless it's an | ||
* `arguments` object, array, string, or jQuery-like collection with a length | ||
* greater than `0` or an object with own enumerable properties. | ||
* | ||
* @private | ||
* @param {string} key The key of the property to get. | ||
* @returns {Function} Returns the new function. | ||
* @static | ||
* @memberOf _ | ||
* @category Lang | ||
* @param {Array|Object|string} value The value to inspect. | ||
* @returns {boolean} Returns `true` if `value` is empty, else `false`. | ||
* @example | ||
* | ||
* _.isEmpty(null); | ||
* // => true | ||
* | ||
* _.isEmpty(true); | ||
* // => true | ||
* | ||
* _.isEmpty(1); | ||
* // => true | ||
* | ||
* _.isEmpty([1, 2, 3]); | ||
* // => false | ||
* | ||
* _.isEmpty({ 'a': 1 }); | ||
* // => false | ||
*/ | ||
function baseProperty(key) { | ||
return function(object) { | ||
return object == null ? undefined : object[key]; | ||
}; | ||
function isEmpty(value) { | ||
return (!isObjectLike(value) || isFunction(value.splice)) | ||
? !size(value) | ||
: !keys(value).length; | ||
} | ||
/** | ||
* Gets the "length" property value of `object`. | ||
* Checks if `value` is classified as a `Function` object. | ||
* | ||
* **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) | ||
* that affects Safari on at least iOS 8.1-8.3 ARM64. | ||
* @static | ||
* @memberOf _ | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. | ||
* @example | ||
* | ||
* @private | ||
* @param {Object} object The object to query. | ||
* @returns {*} Returns the "length" value. | ||
*/ | ||
var getLength = baseProperty('length'); | ||
/** | ||
* Checks if `value` is array-like. | ||
* _.isFunction(_); | ||
* // => true | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is array-like, else `false`. | ||
* _.isFunction(/abc/); | ||
* // => false | ||
*/ | ||
function isArrayLike(value) { | ||
return value != null && isLength(getLength(value)); | ||
function isFunction(value) { | ||
// The use of `Object#toString` avoids issues with the `typeof` operator | ||
// in Safari 8 which returns 'object' for typed array constructors, and | ||
// PhantomJS 1.9 which returns 'function' for `NodeList` instances. | ||
var tag = isObject(value) ? objectToString.call(value) : ''; | ||
return tag == funcTag || tag == genTag; | ||
} | ||
/** | ||
* Checks if `value` is a valid array-like length. | ||
* Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. | ||
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) | ||
* | ||
* **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength). | ||
* @static | ||
* @memberOf _ | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is an object, else `false`. | ||
* @example | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`. | ||
* _.isObject({}); | ||
* // => true | ||
* | ||
* _.isObject([1, 2, 3]); | ||
* // => true | ||
* | ||
* _.isObject(_.noop); | ||
* // => true | ||
* | ||
* _.isObject(null); | ||
* // => false | ||
*/ | ||
function isLength(value) { | ||
return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; | ||
function isObject(value) { | ||
// Avoid a V8 JIT bug in Chrome 19-20. | ||
// See https://code.google.com/p/v8/issues/detail?id=2291 for more details. | ||
var type = typeof value; | ||
return !!value && (type == 'object' || type == 'function'); | ||
} | ||
/** | ||
* Checks if `value` is empty. A value is considered empty unless it is an | ||
* `arguments` object, array, string, or jQuery-like collection with a length | ||
* greater than `0` or an object with own enumerable properties. | ||
* Checks if `value` is object-like. A value is object-like if it's not `null` | ||
* and has a `typeof` result of "object". | ||
* | ||
@@ -89,32 +119,22 @@ * @static | ||
* @category Lang | ||
* @param {Array|Object|string} value The value to inspect. | ||
* @returns {boolean} Returns `true` if `value` is empty, else `false`. | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is object-like, else `false`. | ||
* @example | ||
* | ||
* _.isEmpty(null); | ||
* _.isObjectLike({}); | ||
* // => true | ||
* | ||
* _.isEmpty(true); | ||
* _.isObjectLike([1, 2, 3]); | ||
* // => true | ||
* | ||
* _.isEmpty(1); | ||
* // => true | ||
* | ||
* _.isEmpty([1, 2, 3]); | ||
* _.isObjectLike(_.noop); | ||
* // => false | ||
* | ||
* _.isEmpty({ 'a': 1 }); | ||
* _.isObjectLike(null); | ||
* // => false | ||
*/ | ||
function isEmpty(value) { | ||
if (value == null) { | ||
return true; | ||
} | ||
if (isArrayLike(value) && (isArray(value) || isString(value) || isArguments(value) || | ||
(isObjectLike(value) && isFunction(value.splice)))) { | ||
return !value.length; | ||
} | ||
return !keys(value).length; | ||
function isObjectLike(value) { | ||
return !!value && typeof value == 'object'; | ||
} | ||
module.exports = isEmpty; |
{ | ||
"name": "lodash.isempty", | ||
"version": "3.0.4", | ||
"description": "The modern build of lodash’s `_.isEmpty` as a module.", | ||
"version": "4.0.0", | ||
"description": "The lodash method `_.isEmpty` exported as a module.", | ||
"homepage": "https://lodash.com/", | ||
"icon": "https://lodash.com/icon.svg", | ||
"license": "MIT", | ||
"keywords": "lodash, lodash-modularized, stdlib, util", | ||
"keywords": "lodash, lodash-modularized, stdlib, util, isempty", | ||
"author": "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)", | ||
"contributors": [ | ||
"John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)", | ||
"Benjamin Tan <demoneaux@gmail.com> (https://d10.github.io/)", | ||
"Blaine Bublitz <blaine@iceddev.com> (http://www.iceddev.com/)", | ||
"Kit Cambridge <github@kitcambridge.be> (http://kitcambridge.be/)", | ||
"Blaine Bublitz <blaine@iceddev.com> (https://github.com/phated)", | ||
"Mathias Bynens <mathias@qiwi.be> (https://mathiasbynens.be/)" | ||
@@ -20,8 +18,5 @@ ], | ||
"dependencies": { | ||
"lodash.isarguments": "^3.0.0", | ||
"lodash.isarray": "^3.0.0", | ||
"lodash.isfunction": "^3.0.0", | ||
"lodash.isstring": "^3.0.0", | ||
"lodash.keys": "^3.0.0" | ||
"lodash.keys": "^4.0.0", | ||
"lodash.size": "^4.0.0" | ||
} | ||
} |
@@ -1,4 +0,4 @@ | ||
# lodash.isempty v3.0.4 | ||
# lodash.isempty v4.0.0 | ||
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.isEmpty` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. | ||
The [lodash](https://lodash.com/) method `_.isEmpty` exported as a [Node.js](https://nodejs.org/) module. | ||
@@ -8,3 +8,2 @@ ## Installation | ||
Using npm: | ||
```bash | ||
@@ -15,4 +14,3 @@ $ {sudo -H} npm i -g npm | ||
In Node.js/io.js: | ||
In Node.js: | ||
```js | ||
@@ -22,2 +20,2 @@ var isEmpty = require('lodash.isempty'); | ||
See the [documentation](https://lodash.com/docs#isEmpty) or [package source](https://github.com/lodash/lodash/blob/3.0.4-npm-packages/lodash.isempty) for more details. | ||
See the [documentation](https://lodash.com/docs#isEmpty) or [package source](https://github.com/lodash/lodash/blob/4.0.0-npm-packages/lodash.isempty) 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
2
131
6169
19
+ Addedlodash.size@^4.0.0
+ Addedlodash.keys@4.2.0(transitive)
+ Addedlodash.size@4.2.0(transitive)
- Removedlodash.isarguments@^3.0.0
- Removedlodash.isarray@^3.0.0
- Removedlodash.isfunction@^3.0.0
- Removedlodash.isstring@^3.0.0
- Removedlodash._getnative@3.9.1(transitive)
- Removedlodash.isarguments@3.1.0(transitive)
- Removedlodash.isarray@3.0.4(transitive)
- Removedlodash.isfunction@3.0.9(transitive)
- Removedlodash.isstring@3.0.1(transitive)
- Removedlodash.keys@3.1.2(transitive)
Updatedlodash.keys@^4.0.0