No description, website, or topics provided.
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
test
.gitignore
.testem.json
.travis.yml
LICENCE
README.md
index.js
package.json

README.md

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