Home Manual Reference Source

Function

Static Public Summary
public

chain(tape: Tape): Tape

Converts a tape of tapes of tokens to a tape of tokens.

public

async exhaust(tape: Tape)

Exhausts a tape.

public

fromAsyncIterable(_iterable: AsyncIterable): Tape

Converts an asynchronous iterable to a tape.

public

fromCallable(callable: Function): Tape

Converts a callable to a tape.

public

fromIterable(iterable: Iterable): Tape

Converts an iterable to a tape.

public

fromIterator(iterator: Iterator | AsyncIterator): Tape

Converts an iterator to a tape.

public

fromReadStream(readStream: ReadStream): Tape

Converts a ReadStream object to a tape.

public

ignore(tape: Tape, toignore: Iterable): Tape

Filters a tape by ignoring a given set of tokens.

public

map(callable: Function, tape: Tape): Tape

Applies a callable to each token of a tape.

public

split(tape: Tape, sep: Iterable): Tape

Splits the input tape into a tape of tapes according to some set of separators.

public

toArray(tape: Tape): Promise<any[]>

Converts a tape to an array.

public

Converts a tape to a callable.

public

async * toAsyncIterable(tape: Tape): AsyncIterable

Converts a tape to an asynchronous iterable.

public

toAsyncIterator(tape: Tape): AsyncIterator

Converts a tape to an async iterator.

public

Converts a tape to a string.

Static Private Summary
private

_fromReadStream(readStream: ReadStream): AsyncIterable

Converts a ReadStream object to an async iterable of tokens.

private

async * _fromReadStreamIterator(iterator: AsyncIterator): AsyncIterable

Converts a ReadStream iterator to an async iterable of tokens.

private

_split(tape: Tape, sep: Iterable): AsyncIterableIterator

Same as split, but returns an iterable rather than a tape.

private

asyncIterableChain(iterables: AsyncIterable<AsyncIterable>): AsyncIterable

Utility function to chain an async iterable of async iterables.

private

asyncIterableMap(callable: Function, iterable: AsyncIterable): AsyncIterable

Utility function to apply a sync callable to each item of an async iterable.

private

async * asyncIteratorMap(callable: Function, iterator: AsyncIterator): AsyncIterator

Utility function to apply a sync callable to each item of an async iterator.

private

async skip(tape: Tape, toskip: Iterable): Promise

Outputs the next token of a tape that is not contained in a given toskip set.

Static Public

public chain(tape: Tape): Tape source

Converts a tape of tapes of tokens to a tape of tokens.

Params:

NameTypeAttributeDescription
tape Tape

The tape of tapes of tokens to read from.

Return:

Tape

The converted tape of tokens.

public async exhaust(tape: Tape) source

Exhausts a tape.

Params:

NameTypeAttributeDescription
tape Tape

The tape to read from.

public fromAsyncIterable(_iterable: AsyncIterable): Tape source

import fromAsyncIterable from '@async-abstraction/tape/src/fromAsyncIterable.js'

Converts an asynchronous iterable to a tape.

Params:

NameTypeAttributeDescription
_iterable AsyncIterable

The iterable to convert.

Return:

Tape

The converted tape.

public fromCallable(callable: Function): Tape source

Converts a callable to a tape.

Params:

NameTypeAttributeDescription
callable Function

The callable to convert.

Return:

Tape

The converted tape.

public fromIterable(iterable: Iterable): Tape source

Converts an iterable to a tape.

Params:

NameTypeAttributeDescription
iterable Iterable

The iterable to convert.

Return:

Tape

The converted tape.

public fromIterator(iterator: Iterator | AsyncIterator): Tape source

Converts an iterator to a tape.

Params:

NameTypeAttributeDescription
iterator Iterator | AsyncIterator

The iterator to convert.

Return:

Tape

The converted tape.

public fromReadStream(readStream: ReadStream): Tape source

Converts a ReadStream object to a tape.

Params:

NameTypeAttributeDescription
readStream ReadStream

The ReadStream object to convert.

Return:

Tape

The converted tape.

public ignore(tape: Tape, toignore: Iterable): Tape source

Filters a tape by ignoring a given set of tokens.

Params:

NameTypeAttributeDescription
tape Tape

The tape to filter.

toignore Iterable

The tokens to ignore.

Return:

Tape

The input tape but with some tokens ignored.

public map(callable: Function, tape: Tape): Tape source

Applies a callable to each token of a tape.

Params:

NameTypeAttributeDescription
callable Function

the callable to apply

tape Tape

the tape to process

Return:

Tape

The processed tape.

public split(tape: Tape, sep: Iterable): Tape source

Splits the input tape into a tape of tapes according to some set of separators. See _split for the actual implementation.

Params:

NameTypeAttributeDescription
tape Tape

The input tape.

sep Iterable

An iterable of separators.

Return:

Tape

A tape of tapes.

public toArray(tape: Tape): Promise<any[]> source

Converts a tape to an array.

Params:

NameTypeAttributeDescription
tape Tape

The tape to read from.

Return:

Promise<any[]>

The converted array.

public toAsyncCallable(tape: Tape): Function source

Converts a tape to a callable.

Params:

NameTypeAttributeDescription
tape Tape

The tape to read from.

Return:

Function

The converted callable.

public async * toAsyncIterable(tape: Tape): AsyncIterable source

Converts a tape to an asynchronous iterable.

Params:

NameTypeAttributeDescription
tape Tape

The tape to read from.

Return:

AsyncIterable

The converted iterable.

public toAsyncIterator(tape: Tape): AsyncIterator source

Converts a tape to an async iterator.

Params:

NameTypeAttributeDescription
tape Tape

The tape to read from.

Return:

AsyncIterator

The converted iterator.

public toString(tape: Tape): Promise<string> source

Converts a tape to a string.

Params:

NameTypeAttributeDescription
tape Tape

The tape to read from.

Return:

Promise<string>

The converted string.

Static Private

private _fromReadStream(readStream: ReadStream): AsyncIterable source

import {_fromReadStream} from '@async-abstraction/tape/src/fromReadStream.js'

Converts a ReadStream object to an async iterable of tokens.

Params:

NameTypeAttributeDescription
readStream ReadStream

The ReadStream object to convert.

Return:

AsyncIterable

The converted iterable.

private async * _fromReadStreamIterator(iterator: AsyncIterator): AsyncIterable source

import {_fromReadStreamIterator} from '@async-abstraction/tape/src/fromReadStream.js'

Converts a ReadStream iterator to an async iterable of tokens.

Params:

NameTypeAttributeDescription
iterator AsyncIterator

The ReadStream iterator to convert.

Return:

AsyncIterable

The converted iterable.

private _split(tape: Tape, sep: Iterable): AsyncIterableIterator source

Same as split, but returns an iterable rather than a tape.

Params:

NameTypeAttributeDescription
tape Tape

The input tape.

sep Iterable

An iterable of separators.

Return:

AsyncIterableIterator

An iterable of tapes.

private asyncIterableChain(iterables: AsyncIterable<AsyncIterable>): AsyncIterable source

import asyncIterableChain from '@async-abstraction/tape/src/asyncIterableChain.js'

Utility function to chain an async iterable of async iterables.

Params:

NameTypeAttributeDescription
iterables AsyncIterable<AsyncIterable>

the input iterable of iterables.

Return:

AsyncIterable

The chain of the input iterables.

private asyncIterableMap(callable: Function, iterable: AsyncIterable): AsyncIterable source

Utility function to apply a sync callable to each item of an async iterable.

Params:

NameTypeAttributeDescription
callable Function

The callable to apply.

iterable AsyncIterable

The iterable to process.

Return:

AsyncIterable

The iterable of mapped values.

private async * asyncIteratorMap(callable: Function, iterator: AsyncIterator): AsyncIterator source

Utility function to apply a sync callable to each item of an async iterator.

Params:

NameTypeAttributeDescription
callable Function

The callable to apply.

iterator AsyncIterator

The iterator to process.

Return:

AsyncIterator

The iterator of mapped values.

private async skip(tape: Tape, toskip: Iterable): Promise source

Outputs the next token of a tape that is not contained in a given toskip set.

Params:

NameTypeAttributeDescription
tape Tape

The input tape.

toskip Iterable

The (hashable) tokens to skip.

Return:

Promise

The next token not in toskip.