1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- var baseKeys = require('./_baseKeys'),
- getTag = require('./_getTag'),
- isArguments = require('./isArguments'),
- isArray = require('./isArray'),
- isArrayLike = require('./isArrayLike'),
- isBuffer = require('./isBuffer'),
- isPrototype = require('./_isPrototype'),
- isTypedArray = require('./isTypedArray');
- var mapTag = '[object Map]',
- setTag = '[object Set]';
- var objectProto = Object.prototype;
- var hasOwnProperty = objectProto.hasOwnProperty;
- function isEmpty(value) {
- if (value == null) {
- return true;
- }
- if (isArrayLike(value) &&
- (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
- isBuffer(value) || isTypedArray(value) || isArguments(value))) {
- return !value.length;
- }
- var tag = getTag(value);
- if (tag == mapTag || tag == setTag) {
- return !value.size;
- }
- if (isPrototype(value)) {
- return !baseKeys(value).length;
- }
- for (var key in value) {
- if (hasOwnProperty.call(value, key)) {
- return false;
- }
- }
- return true;
- }
- module.exports = isEmpty;
|