doff
Version:
A powerful tool to free your objects and arrays from unwanted content
30 lines (21 loc) • 571 B
JavaScript
;
// Load modules
const arrayEach = require('./arrayEach');
// Internal logic
const isEnumerable = Object.prototype.propertyIsEnumerable;
// Define exports
module.exports = function enumerableKeys(target, symbols) {
const keys = [];
if (target == null || typeof target !== 'object') {
return keys;
}
keys.push(...Object.keys(target));
if (symbols === true) {
arrayEach(Object.getOwnPropertySymbols(target), (symbol) => {
if (isEnumerable.call(target, symbol)) {
keys.push(symbol);
}
});
}
return keys;
};