sorted-list

Render a reducible of sorted lists

npm install sorted-list
2 downloads in the last week
4 downloads in the last month

sorted-list

build status dependency status

browser support

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

MIT Licenced

npm loves you