Skip to main content

Function: values()

values<Value>(object): Iterable<Value, any, any>

Returns an iterable containing the values of object.

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

Type Parameters

Value

Parameters

object

ReadonlyMap<unknown, Value> | ReadonlySet<Value> | Readonly<Record<PropertyKey, Value>>

Returns

Iterable<Value, any, any>

Example

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

console.log(
pipe(
values([`sloth`, `lazy`, `sleep`]),
reduce(toArray()),
),
)
//=> [ 'sloth', 'lazy, 'sleep' ]

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

console.log(
pipe(
values(new Set([`sloth`, `lazy`, `sleep`])),
reduce(toArray()),
),
)
//=> [ 'sloth', 'lazy, 'sleep' ]

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

Since

v0.1.0

Defined in

generators.d.ts:120