Module

utils/splicearray

@ckeditor/ckeditor5-utils/src/splicearray

module

Filtering

Functions

  • spliceArray( target, source, start, count ) → Array<T>

    Splices one array into another. To be used instead of Array.prototype.splice as the latter may throw "Maximum call stack size exceeded" when passed huge number of items to insert.

    Note: in contrary to Array.splice, this function does not modify the original target.

    spliceArray( [ 1, 2 ], [ 3, 4 ], 0, 0 );	// [ 3, 4, 1, 2 ]
    spliceArray( [ 1, 2 ], [ 3, 4 ], 1, 1 );	// [ 1, 3, 4 ]
    spliceArray( [ 1, 2 ], [ 3, 4 ], 1, 0 );	// [ 1, 3, 4, 2 ]
    spliceArray( [ 1, 2 ], [ 3, 4 ], 2, 0 );	// [ 1, 2, 3, 4 ]
    spliceArray( [ 1, 2 ], [],       0, 1 );	// [ 2 ]
    

    Type parameters

    T

    Parameters

    target : readonly Array<T>

    Array to be spliced.

    source : readonly Array<T>

    Array of elements to be inserted to target.

    start : number

    Index at which nodes should be inserted/removed.

    count : number

    Number of items.

    Returns

    Array<T>

    New spliced array.