UNPKG

iter-tools-es

Version:
30 lines (25 loc) 625 B
const { wrapWithIterableIterator } = require('../../internal/iterable.js'); const { hasOwnProperty } = Object.prototype; function* __objectKeys(obj) { if (obj == null) { return; } for (const key in obj) { if (hasOwnProperty.call(obj, key)) { yield key; } } } exports.__objectKeys = __objectKeys; const objectKeys = /*#__PURE__*/wrapWithIterableIterator(__objectKeys, { validateArgs(args) { if (!(args[0] == null || typeof args[0] === 'object')) { throw new Error('obj argument to objectKeys must be an object, null, or undefined'); } } }); exports.objectKeys = objectKeys;