Skip to main content

Function: entries()

Returns an iterable containing the entries of object.

This differs from Map.prototype.entries in that the returned iterable can be iterated multiple times and differs from Object.entries in that the returned iterable is opaque.

Example

import { entries, pipe, reduce, toArray } from 'lfi'

console.log(
pipe(
entries([`sloth`, `lazy`, `sleep`]),
reduce(toArray()),
),
)
//=> [
//=> [ 0, 'sloth' ],
//=> [ 1, 'lazy' ],
//=> [ 2, 'sleep' ]
//=> ]

console.log(
pipe(
entries({
sloth: 1,
lazy: 2,
sleep: 3,
}),
reduce(toArray()),
),
)
//=> [
//=> [ 'sloth', 1 ],
//=> [ 'lazy', 2 ],
//=> [ 'sleep', 3 ]
//=> ]

console.log(
pipe(
entries(
new Map([
[`sloth`, 1],
[`lazy`, 2],
[`sleep`, 3],
]),
),
reduce(toArray()),
),
)
//=> [
//=> [ 'sloth', 1 ],
//=> [ 'lazy', 2 ],
//=> [ 'sleep', 3 ]
//=> ]
Playground

Since

v0.1.0

Call Signature

entries<Key, Value>(object): Iterable<[Key, Value], any, any>

Type Parameters

Key

Value

Parameters

object

object.entries

() => Iterable<[Key, Value], any, any>

Returns

Iterable<[Key, Value], any, any>

Defined in

generators.d.ts:189

Call Signature

entries<Key, Value>(object): Iterable<[Key, Value], any, any>

Type Parameters

Key extends PropertyKey

Value

Parameters

object

Readonly<Record<Key, Value>>

Returns

Iterable<[Key, Value], any, any>

Defined in

generators.d.ts:192