list or array with fix length, the loop is iterated to maintain the length of array. node > 6 is required. Not dependencies.
npm install --save fix-array-length
#usage
list = FixArrayLength(2)
list.push(0);
list.push(1);
list.push(2);
assert(list.valueOf().length === 2);
assert.deepStrictEqual(list.valueOf(), [ 1, 2 ]);
list.push(0, 1, 2, 3, 4);
assert(list.valueOf().length === 2);
assert.deepStrictEqual(list.valueOf(), [ 3, 4 ]);
list.unshift(2);
list.unshift(4);
list.unshift(5);
assert(list.valueOf().length === 2);
assert.deepStrictEqual(list.valueOf(), [ 5, 4 ]);
list.concat([ 1, 2, 3, 4, 4, 5, 6, 7, 8 ]);
assert(list.valueOf().length === 2);
assert.deepStrictEqual(list.valueOf(), [ 7, 8 ])
length of list
remove elements from init to maintain the length of array.
remove elements from end to maintain the length of array.
alias to pop
concar the array to current list
build the list from array given
return the number of items stored in list.
set the value fo list in index with item given
return the native array
get the item in index given
alias to native one
alias to native one
alias to native one
alias to native one
alias to native one
alias to native one
alias to native one
alias to native one
alias to native one
alias to native one
alias to native one
alias to native one
alias to native one
alias to native one
alias to native one
alias to native one
alias to native one