list
an array watcher
install
$ npm install bloody-list
require
var list =
api
list.create([array]) > l
creates a list
object.
if no array
is passed, an empty new one is used.
list.length([newLength]) > length
gets or sets the array length, returns it.
array mutators
list
provides proxies for array prototype's methods.
returned values are the same as the native ones.
l.push()
l.splice()
l.sort()
l.reverse()
l.pop()
l.shift()
l.unshift()
array mutators
l.push()
l.splice()
l.sort()
l.reverse()
l.pop()
l.shift()
l.unshift()
array accessors / iterators
these are just accessors, list doesn't contain polyfills.
please note that methods like map
return a new array,
not wrapped in a list
.
l.reduceRight()
l.toLocaleString()
l.some()
l.forEach()
l.map()
l.lastIndexOf()
l.toString()
l.join()
l.reduce()
l.slice()
l.filter()
l.every()
events
.on("add", function(item){})
when an item is added.on("remove", function(item){})
when an item is removed.on("change", function(){})
when an item is added or removed.on("sort", function(){})
when the array is sorted.on("reverse", function(){})
when the array is reversed
dispatcher
l.dispatch(cb)
dispatches the changes in the given call stack to cb
changes
object.additions
: array, added itemsobject.deletions
: array, deleted itemsobject.result
: the array
e.g.
ll
l.stopDispatch([cb])
stops dispatching to cb
if passed, or all dispatchers if not.
example
var list = var items = list items items items