Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A tiny module for dealing with associated list-like objects in node.js

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 test
Octocat-spinner-32 README.md
Octocat-spinner-32 alists.js
Octocat-spinner-32 package.json
README.md

alists

This tiny, tiny module is for converting between lists of key-value pairs, such as

[['a', 1], ['b', 2]]

and "equivalent" objects, such as

{ 'a': 1,
  'b': 2 }

in this case.

Such key-valued pairs are being referred to, in this case, as "alists" after the lisp construct

( ('a' . 1) ('b' . 2) )

which, while obviously utilizing cons cells and linked lists, is similar enough for my purposes to be called the same thing.

One purpose for such a thing may be to build objects out of zipped key/val pairs.

Methods:

As you can see, there aren't very many:

toObj :

> alists.toObj([ ['a', 1], ['b', 2] ])
{ a: 1, b: 2 }

toList :

> alists.toList({'a': 1, 'b': 2})
[ [ 'a', 1 ],
  [ 'b', 2 ] ]
Something went wrong with that request. Please try again.