Fast lisp like memory lists
JavaScript
Switch branches/tags
Nothing to show
Latest commit f3855fe Apr 9, 2013 @jwerle jwerle bumped version
Permalink
Failed to load latest commit information.
.gitignore
.npmignore added component.json npmignore gitignore Apr 9, 2013
.travis.yml
Makefile added component.json npmignore gitignore Apr 9, 2013
README.md concat returns and arrays can be passed into list Apr 9, 2013
component.json added component.json npmignore gitignore Apr 9, 2013
index.js bumped version Apr 9, 2013
package.json
test.js initial commit Apr 9, 2013

README.md

mlist

Build Status

install

$ [sudo] npm install mlist

usage

var mlist = require('mlist')
  , set = mlist.set

var cities = mlist()
// set properties to the clients list by key
cities(set('nyc', 'New York City'));
cities(set('tpa', 'Tampa'));
cities(set('la', 'Los Angeles'));
cities(set('bos', 'Boston'));
cities(set('dc', 'Washington D.C'));

// get properties from the clients list by key
cities(get('nyc')); // New York City
cities(get('tpa')); // Tampa
cities(get('la')) ; // Los Angeles
cities(get('bos')); // Boston
cities(get('dc')) ; // Washington D.C

api

prepend(value)

Prepend a value to the list. Values are indexed.

var list = mlist()
  , prepend = mlist.prepend

list(prepend(1))(prepend(2))(prepend(3));
// or
list(prepend(1));
list(prepend(2));
list(prepend(3));

list(get(0)); // 3
list(get(1)); // 2
list(get(2)); // 1

append(value)

Append a value to the list. Values are indexed.

var list = mlist()
  , append = mlist.append

list(append(1))(append(2))(append(3));
// or
list(append(1));
list(append(2));
list(append(3));

list(get(0)); // 1
list(get(1)); // 2
list(get(2)); // 3

get(value)

Get a value from the list by key

var list = mlist()
  , get = mlist.get

list(get('myKey')); // myValue

set(key, value)

Set a value in the list by key

var list = mlist()
  , set = mlist.set

list(set('name', 'Joe'));

concat(value)

Concat values to the list. Accepts any value. Appends all elements of an array like [].concat

var list = mlist()
  , concat = mlist.concat

list(concat(4));
list(concat(['foo', 'bar']));
list(concat(17));

each(callback)

Iterate over each indexed element in the list and execute a function. Similar to `[].forEach

var list = mlist()
  , each = mlist.each

list(each(function(value, key){ }));

map(callback)

Map a new list from an existing list

var list = mlist()
  , map = mlist.map

list(map(function(value){ }));

forIn(callback)

var list = mlist()
  , forIn = mlist.forIn

list(forIn(function(value){ }));

filter(callback)

var list = mlist()
  , filter = mlist.filter

list(filter(function(value){ }));

keys()

var list = mlist()
  , keys = mlist.keys

console.log( list(keys()) )

values()

var list = mlist()
  , values = mlist.values

console.log( list(values()) )

author

Joseph Werle joseph.werle@gmail.com

license

MIT