sorted-list
v0.1.1
Published
Render a reducible of sorted lists
Downloads
14
Readme
sorted-list
Render a reducible of sorted lists
Example
var SortedList = require("sorted-list")
var foldp = require("reducers/reductions")
var map = require("reducers/map")
var fold = require("reducers/fold")
// Accumulate a state representation of a list
var state = foldp(input, function (list, event) {
if (event.type === "add") {
return list.concat(event.value)
}
return list
})
// make sure it's sorted! and that's it's a list of elements
var sorted = map(state, function (list) {
return list.sort(function (a, b) {
return a.timestamp < b.timestamp ? -1 : 1
}).map(function (x) {
return x.view
})
})
var container = document.getElementById("some-container")
// SortedList will ensure it's all in there correctly in
// order of your array
var list = SortedList(sorted, container)
// make sure to fold reducible somewhere!
fold(list, function () {})
Installation
npm install sorted-list
Contributors
- Raynos