|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
669 bytes
|
| Line | |
|---|
| 1 | var _getLength = require('./_getLength.js');
|
|---|
| 2 | var isArray = require('./isArray.js');
|
|---|
| 3 | var isString = require('./isString.js');
|
|---|
| 4 | var isArguments = require('./isArguments.js');
|
|---|
| 5 | var keys = require('./keys.js');
|
|---|
| 6 |
|
|---|
| 7 | // Is a given array, string, or object empty?
|
|---|
| 8 | // An "empty" object has no enumerable own-properties.
|
|---|
| 9 | function isEmpty(obj) {
|
|---|
| 10 | if (obj == null) return true;
|
|---|
| 11 | // Skip the more expensive `toString`-based type checks if `obj` has no
|
|---|
| 12 | // `.length`.
|
|---|
| 13 | var length = _getLength(obj);
|
|---|
| 14 | if (typeof length == 'number' && (
|
|---|
| 15 | isArray(obj) || isString(obj) || isArguments(obj)
|
|---|
| 16 | )) return length === 0;
|
|---|
| 17 | return _getLength(keys(obj)) === 0;
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | module.exports = isEmpty;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.