Arrays.insert()

Insert or append an item and return the result (a new array).

Usage

Hover over inputs/exits for more info.

var Arrays = require('machinepack-arrays');


// Insert or append an item and return the result (a new array).

Arrays.insert({

array: [ '*' ],

index: 1,

value: '*',

}).execSync();

Inputs

array required

The array where the new item should be inserted.

[ '*' ]
index required

The index to insert the new item at.

1
value required

The new item to insert into the array.

'*'

Exits

error

An unexpected error occurred.

notFound

The array does not have enough items for anything to exist at the specified index.

success

OK.

(varies based on provided inputs)