MCPcopy Create free account
hub / github.com/node-modules/utility / getOwnEnumerables

Function getOwnEnumerables

src/object.ts:35–48  ·  view source on GitHub ↗
(obj: any, ignoreNull?: boolean)

Source from the content-addressed store, hash-verified

33 * @return {Array<String>} property names
34 */
35export function getOwnEnumerables(obj: any, ignoreNull?: boolean): Array<string> {
36 if (!obj || typeof obj !== 'object' || Array.isArray(obj)) {
37 return [];
38 }
39 return Object.keys(obj).filter(function(key) {
40 if (ignoreNull) {
41 const value = obj[key];
42 if (value === null || value === undefined || Number.isNaN(value)) {
43 return false;
44 }
45 }
46 return has(obj, key);
47 });
48}
49
50// faster way like `Object.create(null)` to get a 'clean' empty object
51// https://github.com/nodejs/node/blob/master/lib/events.js#L5

Callers

nothing calls this directly

Calls 1

hasFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…