diff --git a/projects/micro-dash/src/lib/object/functions.ts b/projects/micro-dash/src/lib/object/functions.ts index 6dc7c41d..71d061c1 100644 --- a/projects/micro-dash/src/lib/object/functions.ts +++ b/projects/micro-dash/src/lib/object/functions.ts @@ -1,4 +1,4 @@ -import { isFunction, keys } from '../../public-api'; +import { isFunction } from '../../public-api'; import { StringifiedKey } from '../interfaces'; /** @@ -6,12 +6,12 @@ import { StringifiedKey } from '../interfaces'; * * Contribution to minified bundle size, when it is the only function imported: * - Lodash: 3,504 bytes - * - Micro-dash: 310 bytes + * - Micro-dash: 143 bytes */ export function functions(obj: T): Array> { - return keys(obj).filter( + return Object.getOwnPropertyNames(obj).filter( (key) => key !== 'constructor' && - isFunction(Object.getOwnPropertyDescriptor(obj, key)?.value), - ); + isFunction(Object.getOwnPropertyDescriptor(obj, key)!.value), + ) as Array>; } diff --git a/projects/micro-dash/src/lib/object/keys.ts b/projects/micro-dash/src/lib/object/keys.ts index 707eead6..7fb368f9 100644 --- a/projects/micro-dash/src/lib/object/keys.ts +++ b/projects/micro-dash/src/lib/object/keys.ts @@ -8,7 +8,7 @@ import { Nil, StringifiedKey } from '../interfaces'; * * Contribution to minified bundle size, when it is the only function imported: * - Lodash: 3,326 bytes - * - Micro-dash: 148 bytes + * - Micro-dash: 135 bytes */ export function keys(object: T | Nil): Array> { @@ -21,9 +21,5 @@ export function keys(object: T | Nil): Array> { /** @hidden */ export function keysOfNonArray(object: T | Nil): Array> { - let val: string[] = []; - if (object) { - val = Object.getOwnPropertyNames(object); - } - return val as any; + return object ? (Object.getOwnPropertyNames(object) as any) : []; }