npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lists-js

v1.0.3

Published

list data structure based on pairs

Downloads

5

Readme

MaintainabilityTest CoverageBuild Status

js-lists

Install

npm install lists-js

Using

import {cons, head, tail, isEmpty, toString, has, count, reverse, isList, push,
        concat, map, filter, reduce, } from 'lists-js'

const list = cons(1, 2, 3); // (1, 2, 3)
head(list); // 1
tail(list); // (2, 3)
isList(list); // true
isList('text'); // false
push(0, list); // (0, 1, 2, 3)
toString(list); // (1, 2, 3)
has(3, list); // true
count(list); // 3

Documentation

Table of Contents

cons

Make a list

Parameters

  • args ...any

Examples

cons(1, 2, 3); // (1, 2, 3)
cons(); // ()

Returns list

isList

Check if arguments is list

Parameters

  • list

Examples

isList(cons()); // true
isList(cons(1, 2)); // true
isList('text'); // false

Returns boolean

head

Get head element

Parameters

  • list

Examples

head(cons(1, 2)); // 1

Returns any

tail

Get tail element

Parameters

  • list

Examples

tail(cons(1, 2, 3)); // (2, 3)

Returns any

isEmpty

Check if list is empty

Parameters

  • list

Examples

isEmpty(cons(1, 2)); // false
isEmpty(cons()); //true

Returns boolean

push

Add element to list

Parameters

  • element
  • list

Examples

push(3, cons(2, 1)); // (3, 2, 1)

Returns list

toString

Convert list to string

Parameters

  • list

Examples

toString(cons(1, 2, 3)); // (1, 2, 3);
toString(cons(1, cons(2, 3))); // (1, (2, 3));

Returns string

has

Check if list has an element

Parameters

  • value
  • list

Examples

has(1, cons(1, 2)); // true
has(5, cons(1, 2)); // false

Returns boolean

count

Get number of elements in a list

Parameters

  • list

Examples

count(cons(1, 2, 3)); // 3
count(cons()); // 0

Returns int

reverse

Reverse list

Parameters

  • list

Examples

reverse(cons(1, 2, 3)); // (3, 2, 1)

Returns list

concat

Join 2 lists

Parameters

  • list1
  • list2

Examples

concat(cons(1, 2), cons(3, 4)); // (1, 2, 3, 4)

Returns list

map

Map list

Parameters

  • f
  • list

Examples

const list = cons(1, 2, 3);
map(el => el ** 2, list); // (1, 4, 9)

Returns list

filter

Filter list

Parameters

  • f
  • list

Examples

const list = cons(-1, 2, -5, 0, 9);
filter(el => el > 0, list); // (2, 9)

Returns list

reduce

Reduce list

Parameters

  • f
  • acc
  • elements

Examples

reduce((el, acc) => acc + 1, 0, cons(1, 2, 3)); // 3

Returns any