UNPKG

typedash

Version:

modern, type-safe collection of utility functions

1 lines 748 B
{"version":3,"sources":["../../src/functions/objectFromEntries/objectFromEntries.ts"],"names":[],"mappings":";AAAO,IAAM,oBAAuC,OAAO","sourcesContent":["export const objectFromEntries: ObjectFromEntries = Object.fromEntries;\n\n/**\n * Returns a new object from an iterable of key-value pairs.\n * Same as `Object.fromEntries()` but returns a typed object.\n * @param entries An iterable object that contains key-value entries.\n * @returns A new object from the given iterable of key-value pairs.\n * @example\n * ```ts\n * objectFromEntries([\n * ['a', 1],\n * ['b', 2],\n * ['c', 3]\n * ]);\n * // { a: 1, b: 2, c: 3 }\n */\ntype ObjectFromEntries = <K extends PropertyKey, V>(\n entries: Iterable<readonly [K, V]>\n) => Record<K, V>;\n"]}