Class: TokenAccumulator

wt2html/TokenTransformManager~TokenAccumulator(manager, parentCB)

Token accumulators buffer tokens between asynchronous processing points, and return fully processed token chunks in-order and as soon as possible. They support the AsyncTokenTransformManager.

They receive tokens from sibling transformers and child transformers, merge them in-order (all-child-tokens followed by all-sibling-tokens) and pass them to whoever wanted them (another sibling or a parent).

Constructor

new TokenAccumulator(manager, parentCB)

...
Parameters:
Name Type Description
manager TokenTransformManager
parentCB function

The callback to call after we've finished accumulating.

Source:

Methods

_callParentCB() → {function}

...

append(tokens)

Append tokens to an accumulator.

Append tokens to an accumulator.

Parameters:
Name Type Description
tokens Array.<Token>
Source:

concatTokens(tokens)

Concatenates an array of tokens to the tokens kept in siblingChunks.

Concatenates an array of tokens to the tokens kept in siblingChunks. If the ranks are the same, just concat to the last chunk. If not, set apart as its own chunk.

Parameters:
Name Type Description
tokens Array
Source:

emitTokens(async)

Sends all accumulated tokens in order.

Sends all accumulated tokens in order.

Parameters:
Name Type Description
async boolean
Source:

push(token)

Push a token into the accumulator.

Push a token into the accumulator.

Parameters:
Name Type Description
token Token
Source:

receiveToksFromChild(ret) → {function|null}

Receives tokens from a child accum/pipeline/cb.

Receives tokens from a child accum/pipeline/cb.

Parameters:
Name Type Description
ret Object
Properties
Name Type Description
tokens Array
async boolean
Source:
Returns:

New parent callback for caller or falsy value.

Type
function | null

receiveToksFromSibling(ret) → {function|null}

Receives tokens from a sibling accum/cb.

Receives tokens from a sibling accum/cb.

Parameters:
Name Type Description
ret Object
Properties
Name Type Description
tokens Array
async boolean
Source:
Returns:

New parent callback for caller or falsy value.

Type
function | null

siblingDone()

Mark the sibling as done (normally at the tail of a chain).

Mark the sibling as done (normally at the tail of a chain).

Source: