PavePave
Home
Guide
API
Sandbox
  • English
  • 日本語
GitHub
Home
Guide
API
Sandbox
  • English
  • 日本語
GitHub
  • Iter

@baku89/pave v0.7.1


@baku89/pave / Iter

Iter

A collection of utility functions for working with iterables.

Interfaces

ResampleOptions

Defined in: Iter.ts:107

Properties

PropertyTypeDescription
align?"uniform" | "start" | "center" | "end"How to align the resampled values. Default 'uniform'
count?numberThe number of samples to generate. If this is specified, the step will be ignored and the number will be distributed uniformly across the range. Default undefined
emitFrom?booleanWhether to emit the from value. Default true
emitTo?booleanWhether to emit the to value. Default true
step?numberThe step size to use for resampling. If not provided, the step size will be calculated based on the count and align options. Default to - from

Functions

enumerate()

enumerate<T>(iter): Generator<[number, T]>

Defined in: Iter.ts:98

Yields tuples of values from the input generator, where its first element is the index of the value and the second one is the value itself.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
iterIterable<T>The input generator.

Returns

Generator<[number, T]>


range()

range(from, to, step, maxCount): Generator<number>

Defined in: Iter.ts:16

Iterates over a range between [from, to) with a given step, while avoiding infinite loops.

Parameters

ParameterTypeDefault valueDescription
fromnumberundefinedThe start of the range.
tonumberundefinedThe end of the range.
stepnumberundefinedThe step size.
maxCountnumber1_000_000The maximum number of values to yield.

Returns

Generator<number>

A generator that yields values in the range.


rangeWithOffset()

rangeWithOffset(from, to, step, offset, maxCount?): Generator<number>

Defined in: Iter.ts:55

Yield from, to, and values between them with a given step and offset. It avoids infinite loops by clamping the number of iterations.

Parameters

ParameterTypeDescription
fromnumberThe start of the range.
tonumberThe end of the range.
stepnumberThe step size.
offsetnumberThe offset to apply to the range.
maxCount?numberThe maximum number of values to yield.

Returns

Generator<number>


resample()

resample(from, to, __namedParameters): Generator<number, void, unknown>

Defined in: Iter.ts:135

Parameters

ParameterType
fromnumber
tonumber
__namedParametersResampleOptions

Returns

Generator<number, void, unknown>


tuple()

tuple<T>(iter): Generator<[T, T]>

Defined in: Iter.ts:82

Yields tuples of values from the input generator, where each tuple contains the current and previous values.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
iterIterable<T>The input generator.

Returns

Generator<[T, T]>

A generator that yields tuples of values.

Edit this page