Skip to main content

Variable: entries()

const entries: {<Key, Value>(object): Iterable<[Key, Value]>; <Key, Value>(object): Iterable<[Key, Value]>; }

Defined in: generators.d.ts:188

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.

Call Signature​

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

Type Parameters​

Key​

Key

Value​

Value

Parameters​

object​

entries​

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

Returns​

Iterable<[Key, Value]>

Call Signature​

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

Type Parameters​

Key​

Key extends PropertyKey

Value​

Value

Parameters​

object​

Readonly<Record<Key, Value>>

Returns​

Iterable<[Key, Value]>

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