Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "utils/shift/docs/types/index.d"

Index

Functions

Functions

Export assignment shift

  • Removes and returns the first element of a collection.

    Notes

    • The function returns an array with two elements: the shortened collection and the removed element.
    • If the input collection is a typed array whose length is greater than 0, the first return value does not equal the input reference.
    • For purposes of generality, always treat the output collection as distinct from the input collection.

    Parameters

    Returns [ Collection , any ]

    updated collection and the removed element

    Example

    var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];
    
    var out = shift( arr );
    // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]

    Example

    var Float64Array = require( `@stdlib/array/float64` );
    
    var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
    // returns <Float64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0 ]
    
    var out = shift( arr );
    // returns [ <Float64Array>[ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]