UNPKG

@studiometa/js-toolkit

Version:

A set of useful little bits of JavaScript to boost your project! 🚀

18 lines (17 loc) • 621 B
import { isFunction } from "../is.js"; function getAllProperties(object, props = [], testFn = null) { const proto = Object.getPrototypeOf(object); if (proto === Object.prototype || proto === null) { return props; } let foundProps = Object.getOwnPropertyNames(proto); if (isFunction(testFn)) { foundProps = foundProps.filter((name) => testFn(name, proto)); } const formatedProps = foundProps.map((name) => [name, proto]).reduce((acc, val) => [...acc, val], props); return getAllProperties(proto, formatedProps, testFn); } export { getAllProperties }; //# sourceMappingURL=getAllProperties.js.map