New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

alists

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alists

Some helper functions to work with associative lists.

0.0.2
latest
Source
npm
Version published
Maintainers
1
Created
Source

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 ] ]

FAQs

Package last updated on 08 Dec 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts