Comparing version 2.7.4 to 2.7.5
@@ -6,2 +6,10 @@ 'use strict'; | ||
}); | ||
exports.isEmptyObjectOrArray = exports.makeFlattenedShallow = undefined; | ||
var _typeOf = require('type-of'); | ||
var _typeOf2 = _interopRequireDefault(_typeOf); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/* | ||
@@ -31,2 +39,6 @@ * Returns a shallow version of the shallow object to remove redundancy | ||
if (isEmptyObjectOrArray(subject[keyChain])) { | ||
shallow = false; | ||
} | ||
if (!shallow) { | ||
@@ -37,2 +49,18 @@ resp[keyChain] = subject[keyChain]; | ||
return resp; | ||
}; | ||
/* | ||
* Returns true if we're dealing with an empty array or object | ||
* | ||
* @param {object} subject the array or object to check | ||
* @returns {boolean} | ||
*/ | ||
var isEmptyObjectOrArray = exports.isEmptyObjectOrArray = function isEmptyObjectOrArray(subject) { | ||
if ((0, _typeOf2.default)(subject) === 'object' || (0, _typeOf2.default)(subject) === 'array') { | ||
if (Object.keys(subject).length === 0) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; |
{ | ||
"name": "objob", | ||
"version": "2.7.4", | ||
"version": "2.7.5", | ||
"description": "A tool for controlling and manipulating javascript object fields and output.", | ||
@@ -5,0 +5,0 @@ "main": "lib/objob.js", |
@@ -0,1 +1,3 @@ | ||
import type from 'type-of'; | ||
/* | ||
@@ -25,2 +27,6 @@ * Returns a shallow version of the shallow object to remove redundancy | ||
if(isEmptyObjectOrArray(subject[keyChain])) { | ||
shallow = false; | ||
} | ||
if(!shallow) { | ||
@@ -32,1 +38,18 @@ resp[keyChain] = subject[keyChain]; | ||
}; | ||
/* | ||
* Returns true if we're dealing with an empty array or object | ||
* | ||
* @param {object} subject the array or object to check | ||
* @returns {boolean} | ||
*/ | ||
export let isEmptyObjectOrArray = function(subject) { | ||
if(type(subject) === 'object' || type(subject) === 'array'){ | ||
if(Object.keys(subject).length === 0) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; |
661117
3233