util-ex
Version:
Browser-friendly enhanced util fully compatible with standard node.js
38 lines (36 loc) • 1.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
exports.getNonEnumerableNames = getNonEnumerableNames;
const getKeys = Object.keys;
const getOwnPropertyNames = Object.getOwnPropertyNames;
/**
* Returns an array of non-enumerable owner property names of an object.
*
* @param {Object} aObject - The object to retrieve non-enumerable property names from.
* @returns {Array.<string>} - An array of non-enumerable property names of the object.
*
* @example
*
* var obj = Object.create(null, {
* a: { value: 1 },
* b: { value: 2, enumerable: true }
* });
*
* var nonEnumProps = getNonEnumerableNames(obj); // nonEnumProps = ['a']
*/
function getNonEnumerableNames(aObject) {
let keys, result;
result = getOwnPropertyNames(aObject);
if (result.length) {
keys = getKeys(aObject);
result = result.filter(k => {
return keys.indexOf(k) === -1;
});
}
return result;
}
;
var _default = exports.default = getNonEnumerableNames;