Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "patch-array"

Index

Functions

Functions

patchArray

  • Reducer for Patch based array edits. Only numeric indices are supported (i.e. NO nested edits, use patchObj for that purpose).

    remarks

    Unless immutable is false (default: true), all edits are performed in a non-destructive manner.

    The following patch types are supported:

    • SET
    • UPDATE
    • INSERT
    • DELETE
    example
    // direct invocation
    patchArray(
        true,
        [1, 2, 3],
        [
            [Patch.SET, 0, 42],
            [Patch.UPDATE, 1, (x, n) => x * n, 10],
            [Patch.INSERT, 2, [10, 11]],
            [Patch.DELETE, 3]
        ]
    );
    // [ 42, 20, 10, 3 ]

    Type parameters

    • T

    Parameters

    • Optional immutable: undefined | false | true

    Returns Reducer<T[], PatchArrayOp<T> | PatchArrayOp<T>[]>

  • Type parameters

    • T

    Parameters

    Returns T[]

Generated using TypeDoc