From 357ae59659a16ade8845f301110630d05f98d743 Mon Sep 17 00:00:00 2001 From: gcanti Date: Thu, 28 Apr 2022 09:19:31 +0200 Subject: [PATCH] ReadonlyRecord: do not import ReadonlyArray module --- src/ReadonlyRecord.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ReadonlyRecord.ts b/src/ReadonlyRecord.ts index f7a029640..e18e40cb4 100644 --- a/src/ReadonlyRecord.ts +++ b/src/ReadonlyRecord.ts @@ -7,7 +7,6 @@ * @since 2.5.0 */ import { Applicative, Applicative1, Applicative2, Applicative2C, Applicative3, Applicative3C } from './Applicative' -import * as RA from './ReadonlyArray' import { Compactable1 } from './Compactable' import { Either } from './Either' import { Eq, fromEquals } from './Eq' @@ -1107,8 +1106,13 @@ export const toEntries = toReadonlyArray * * assert.deepStrictEqual(fromEntries([['a', 1], ['b', 2], ['a', 3]]), { b: 2, a: 3 }) */ -export const fromEntries = (fa: ReadonlyArray): Record => - fromFoldable(Se.last(), RA.Foldable)(fa) +export const fromEntries = (fa: ReadonlyArray): Record => { + const out: Record = {} + for (const a of fa) { + out[a[0]] = a[1] + } + return out +} /** * Test if every value in a `ReadonlyRecord` satisfies the predicate.