remeda
Version:
A utility library for JavaScript and Typescript.
1 lines • 1.82 kB
Source Map (JSON)
{"version":3,"file":"entries.cjs","names":["purry"],"sources":["../src/entries.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-object-type --\n * We want to match the typing of the built-in Object.entries as much as\n * possible!\n */\nimport type { Simplify, ValueOf } from \"type-fest\";\nimport { purry } from \"./purry\";\nimport type { ToString } from \"./internal/types/ToString\";\n\ntype Entry<T> = Simplify<\n ValueOf<{\n // `Object.entries` only returns enumerable keys, skipping symbols.\n [P in Exclude<keyof T, symbol>]-?: [\n // and all keys are converted to strings.\n key: ToString<P>,\n // Optionality doesn't play a factor in the result of entries because its\n // a typing thing, not a runtime thing. We need to remove any `undefined`\n // added just because the prop is optional.\n value: Required<T>[P],\n ];\n }>\n>;\n\n/**\n * Returns an array of key/values of the enumerable properties of an object.\n *\n * @param data - Object to return keys and values of.\n * @signature\n * R.entries(object)\n * @example\n * R.entries({ a: 1, b: 2, c: 3 }); // => [['a', 1], ['b', 2], ['c', 3]]\n * @dataFirst\n * @category Object\n */\nexport function entries<T extends {}>(data: T): Array<Entry<T>>;\n\n/**\n * Returns an array of key/values of the enumerable properties of an object.\n *\n * @signature\n * R.entries()(object)\n * @example\n * R.pipe({ a: 1, b: 2, c: 3 }, R.entries()); // => [['a', 1], ['b', 2], ['c', 3]]\n * @dataLast\n * @category Object\n */\nexport function entries(): <T extends {}>(data: T) => Array<Entry<T>>;\n\nexport function entries(...args: ReadonlyArray<unknown>): unknown {\n return purry(Object.entries, args);\n}\n"],"mappings":"wCA+CA,SAAgB,EAAQ,GAAG,EAAuC,CAChE,OAAOA,EAAAA,EAAM,OAAO,QAAS,EAAK"}