Git Product home page Git Product logo

observ-varlist's Introduction

observ-varlist Build Status

An observable list that can grow negatively or positively

Install

$ npm install --save observ-varlist

Usage

var ObservList = require('observ-varlist')
var toArray = require('observ-varlist/to-array')

var list = ObservList(['b', 'c'])

list.prepend('a')

list.from() // => -1
list.count() // => 3

list() // => {from: -1, count: 3, '-1': 'a', 0: 'b', 1: 'c'}
toArray(list) // => ObservArray(['a', 'b', 'c'])
toArray(list()) // => ['a', 'b', 'c']

API

ObservList([initial], [constructor]) -> observList

initial

Optional Type: object|array

Either an array, or an object containing from: Number, count: Number, and optional indices containing data between from and from + count.

constructor

Optional Type: function

Every item put into the list will go through this constructor. Whatever the constructor returns will be stored in the list.

observList Instance

Returned from the ObservList constructor, this is an observable with the following methods:

list.prepend(item)
  • Expands the list backwards and inserts the item. Can go into negative indexes.
list.append(item)
  • Expands the list forwards and inserts the item.
list.reset(data)

Resets the list. Data is either an array or an object containing from: Number, count: Number, and optional indices containing data between from and from + count.

list.forEach, list.map, list.filter, list.find

Convenience functions that are like the array methods.

License

MIT © Andrew Joslin

observ-varlist's People

Contributors

ajoslin avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.