UNPKG

iter-tools-es

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