@jasonsbarr/collections

Awesome collection types for fluent functional programming

Usage no npm install needed!

<script type="module">
  import jasonsbarrCollections from 'https://cdn.skypack.dev/@jasonsbarr/collections';
</script>

README

@jasonsbarr/collections

Iterable collections in JavaScript with functionalities that far outstrip the native capabilities of JavaScript Arrays, Objects, Sets, and Maps.

Collections include:

  • Dict - a hash table or dictionary-like data structure intended for use with single-type values
  • List - a linked list using Array-based cells
  • Nil - represents the empty List for safe use with what would otherwise be null and undefined values
  • Range - if all you need is to iterate over a range of numbers, this is what you need
  • Map - like native JavaScript Maps, but with additional methods and functionality
  • Tuple - immutable, Array-like collection
  • Set - Indexed collection of unique values based on structural (value) equality

Basic Usage

Import the collections you need and use as follows:

import { Tuple } from "@jasonsbarr/collections/lib/Tuple";
import { isOdd } from "@jasonsbarr/functional-core/lib/predicates/isOdd";

const nums = Tuple(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
const evens = nums.reject(isOdd);

console.log(evens.inspect()); // -> Tuple(2, 4, 6, 8, 10)

Documentation

Documentation