array-list
array-list copied to clipboard
Simple array list implementation.
array-list
Simple array list implementation.
Install
$ npm install array-list --save
Usage
var arrayList = require('array-list')
// with limit
var arr = arrayList(100)
// without limit
var arr = arrayList()
API
arrayList([limit])
limit
Type: integer
Specify the limit of the array. It's need to be a positive integer number.
.size()
Returns how many elements are stored in the array list.
This value is different from .length, that returns the size reserved for the array.
.push({element})
It adds a new element in the array list.
This methods could be throw an error if:
- You don't provide a valid element.
- The array list is full.
.get([element])
It gets the elements in the array list.
You can specify an index, in other case the methods will return all the elements.
.clear()
It removes all the elements in the array list.
.flush()
It returns a copy of the elements in array list.
An alias from concat .get
+ .clear
.
.isEmpty()
Returns true
is the .size
is 0; false
in other case.
.isFull()
Returns true
is the .size
is equal to limit
; false
in other case.
Related
- array-future – A collection of Array prototypes prollyfills as proposition for ECMAScript 7.
License
MIT © Kiko Beats.