deep-trails - v3.0.0-beta.3
    Preparing search index...

    Type Alias Control<K, V>

    Specifies control flags to alter the behavior of deep iteration traversal.

    Notes:

    • The effects of using this object are applied after the callback is called.
    • This object should be used only in callbacks for deepIterate.

    Evaluation order:

    • useEntry()
    • finishNow
    • finishAfterNode
    • stopParentNow
    • stopParentAfterNode
    • skipNode
    • skipKey
    • skipValue

    3.0.0-beta.0

    type Control<K = unknown, V = unknown> = {
        finishAfterNode: boolean;
        finishNow: boolean;
        skipKey: boolean;
        skipNode: boolean;
        skipValue: boolean;
        stopParentAfterNode: boolean;
        stopParentNow: boolean;
        useEntry: (key?: K, value?: V) => 0 | 1 | 2 | 3;
    }

    Type Parameters

    • K = unknown
    • V = unknown
    Index

    Properties

    finishAfterNode: boolean

    Finish the entire traversal after iterating over the current child.

    Once requested, it cannot be cancelled.

    control.finishAfterNode = typeOf(child.value) === "Set"
    
    finishNow: boolean

    Finish the entire traversal when the current call to the callback ends.

    control.finishNow = child.key === "finish"
    
    skipKey: boolean

    Skips iterating over the key of the current child.

    control.skipKey = !isPlainObject(child.key)
    
    skipNode: boolean

    Skips iterating over the key and value of the current child.

    control.skipNode = child.depth > 10
    
    skipValue: boolean

    Skips iterating over the value of the current child.

    control.skipValue = !Array.isArray(child.value)
    
    stopParentAfterNode: boolean

    Stops iterating over the current parent after deeply iterating over the current child.

    Once requested, it cannot be cancelled.

    control.stopParentAfterNode = child.index >= 10
    
    stopParentNow: boolean

    Stops iterating over the current parent when this call to the callback ends.

    control.stopParentNow = child.index > 20
    
    useEntry: (key?: K, value?: V) => 0 | 1 | 2 | 3

    Assigns the provided key and value to the context of the current child.

    If the path is an array of keys and a new key is received, the last key will be replaced.

    Type Declaration

      • (key?: K, value?: V): 0 | 1 | 2 | 3
      • Parameters

        • Optionalkey: K
        • Optionalvalue: V

        Returns 0 | 1 | 2 | 3

        The number of things that will be updated in the context.

        • 0 - Nothing.
        • 1 - The value.
        • 2 - The key and the path.
        • 3 - The value, the key, and the path.
    // Stringifying non-string values
    if (typeof child.value !== "string") {
    const newValue = String(child.value);
    parent.value[child.key] = newValue;
    control.useEntry(child.key, newValue); // returns 1
    }
    // Changing elements in sets
    const object = parent.value;
    if (object instanceof Set && typeof child.value !== "string") {
    const newValue = String(child.value);
    object.add(newValue);
    object.delete(child.value);
    control.useEntry(newValue, newValue); // returns 3
    }