Skip to content

Commit 4cf715f

Browse files
authored
Merge pull request #2840 from jgonggrijp/empty-validation-warning
2 parents 114a451 + bfe5768 commit 4cf715f

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

index.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,11 +1732,13 @@ <h2 id="objects">Object Functions</h2>
17321732
</pre>
17331733

17341734
<p id="isEmpty">
1735-
<b class="header">isEmpty</b><code>_.isEmpty(object)</code>
1735+
<b class="header">isEmpty</b><code>_.isEmpty(collection)</code>
17361736
<br />
1737-
Returns <i>true</i> if an enumerable <b>object</b> contains no
1738-
values (no enumerable own-properties). For strings and array-like
1739-
objects <tt>_.isEmpty</tt> checks if the length property is 0.
1737+
Returns <i>true</i> if <b>collection</b> has no elements. For strings
1738+
and array-like objects <tt>_.isEmpty</tt> checks if the length property
1739+
is 0. For other objects, it returns <i>true</i> if the object has no
1740+
enumerable own-properties. Note that primitive numbers, booleans and
1741+
symbols are always empty by this definition.
17401742
</p>
17411743
<pre>
17421744
_.isEmpty([1, 2, 3]);

modules/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,8 @@ export function isEqual(a, b) {
12961296
// An "empty" object has no enumerable own-properties.
12971297
export function isEmpty(obj) {
12981298
if (obj == null) return true;
1299+
// Skip the more expensive `toString`-based type checks if `obj` has no
1300+
// `.length`.
12991301
if (isArrayLike(obj) && (isArray(obj) || isString(obj) || isArguments(obj))) return obj.length === 0;
13001302
return keys(obj).length === 0;
13011303
}

underscore.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

underscore.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)