yallist
basic usage
var yallist = require('yallist')
var myList = yallist.create([1, 2, 3])
myList.push('foo')
myList.unshift('bar')
// of course pop() and shift() are there, too
console.log(myList.toArray()) // ['bar', 1, 2, 3, 'foo']
myList.forEach(function (k) {
// walk the list head to tail
})
myList.forEachReverse(function (k, index, list) {
// walk the list tail to head
})
var myDoubledList = myList.map(function (k) {
return k + k
})
// now myDoubledList contains ['barbar', 2, 4, 6, 'foofoo']
// mapReverse is also a thing
var myDoubledListReverse = myList.mapReverse(function (k) {
return k + k
}) // ['foofoo', 6, 4, 2, 'barbar']
var reduced = myList.reduce(function (set, entry) {
set += entry
return set
}, 'start')
console.log(reduced) // 'startfoo123bar'api
Yallist
Yallist.create(..)
yallist.head
yallist.tail
yallist.length
yallist.toArray()
yallist.forEach(fn, [thisp])
yallist.forEachReverse(fn, [thisp])
yallist.get(n)
yallist.getReverse(n)
yallist.map(fn, thisp)
yallist.mapReverse(fn, thisp)
yallist.pop()
yallist.push(item, ...)
yallist.reduce(fn, initialValue)
yallist.reduceReverse
yallist.reverse
yallist.shift()
yallist.slice([from], [to])
yallist.sliceReverse([from], [to])
yallist.toArray()
yallist.toArrayReverse()
yallist.unshift(item, ...)
yallist.unshiftNode(node)
yallist.pushNode(node)
yallist.removeNode(node)
Yallist.Node
node.next
node.prev
node.value
node.list
Last updated