sorted-list

0.1.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i sorted-list

Weekly Downloads

1

Version

0.1.1

License

none

Last publish

Collaborators

  • raynos