UNPKG

typedash

Version:

modern, type-safe collection of utility functions

32 lines (29 loc) 1 kB
import { objectEntries } from './chunk-HOKNVEWK.js'; import { createTypeGuard } from './chunk-AM6QCXAM.js'; import { castArray } from './chunk-ETIDRXKH.js'; // src/functions/_internal/filterObject/createObjectPredicate.ts function createObjectPredicate(propertiesOrPredicate) { return typeof propertiesOrPredicate === "function" ? propertiesOrPredicate : createPropertiesPredicate(propertiesOrPredicate); } function createPropertiesPredicate(properties) { const isKnownProperty = createTypeGuard(castArray(properties)); return (_value, key) => isKnownProperty(key); } // src/functions/_internal/filterObject/filterObject.ts function filterObject(object, predicate) { if (object == null) { return {}; } return Object.fromEntries( objectEntries(object).filter( ([key, value]) => predicate( value, key, object ) ) ); } export { createObjectPredicate, filterObject }; //# sourceMappingURL=out.js.map //# sourceMappingURL=chunk-ZOJ4KZMQ.js.map