Skip to content

Commit

Permalink
ReadonlyRecord: do not import ReadonlyArray module
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti committed Apr 28, 2022
1 parent 802af2f commit 357ae59
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/ReadonlyRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -1107,8 +1106,13 @@ export const toEntries = toReadonlyArray
*
* assert.deepStrictEqual(fromEntries([['a', 1], ['b', 2], ['a', 3]]), { b: 2, a: 3 })
*/
export const fromEntries = <A>(fa: ReadonlyArray<readonly [string, A]>): Record<string, A> =>
fromFoldable(Se.last<A>(), RA.Foldable)(fa)
export const fromEntries = <A>(fa: ReadonlyArray<readonly [string, A]>): Record<string, A> => {
const out: Record<string, A> = {}
for (const a of fa) {
out[a[0]] = a[1]
}
return out
}

/**
* Test if every value in a `ReadonlyRecord` satisfies the predicate.
Expand Down

0 comments on commit 357ae59

Please sign in to comment.