From cb2a9c2c92233eed2f61d3195465dfa1a5128658 Mon Sep 17 00:00:00 2001 From: bowzee Date: Sun, 27 Nov 2022 01:01:10 +0800 Subject: [PATCH 1/2] feat(Record/fromEntries): implement generic record key --- src/Record.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Record.ts b/src/Record.ts index 8a86f9396..882002b85 100644 --- a/src/Record.ts +++ b/src/Record.ts @@ -808,7 +808,7 @@ export const toEntries = toArray * @since 2.12.0 * @category conversions */ -export const fromEntries = (fa: Array<[string, A]>): Record => fromFoldable(Se.last(), A.Foldable)(fa) +export const fromEntries = (fa: Array<[K, A]>): Record => fromFoldable(Se.last(), A.Foldable)(fa) /** * Create a `Record` from a foldable collection using the specified functions to From 7e9d14811c93d4dcfe9d06e1cc783b59952689f8 Mon Sep 17 00:00:00 2001 From: bowzee Date: Sun, 27 Nov 2022 01:01:23 +0800 Subject: [PATCH 2/2] feat(ReadonlyRecord/fromEntries): implement generic record key --- src/ReadonlyRecord.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ReadonlyRecord.ts b/src/ReadonlyRecord.ts index a7af5d0fe..13b24eb58 100644 --- a/src/ReadonlyRecord.ts +++ b/src/ReadonlyRecord.ts @@ -1120,8 +1120,8 @@ export const toEntries = toReadonlyArray * @since 2.12.0 * @category conversions */ -export const fromEntries = (fa: ReadonlyArray): ReadonlyRecord => { - const out: Record = {} +export const fromEntries = (fa: ReadonlyArray): ReadonlyRecord => { + const out: Record = Object.create(null) for (const a of fa) { out[a[0]] = a[1] }