@frctl/list
v2.1.1
Published
Simple immutable object collections.
Downloads
38
Readme
List
List is an array-like object collection class for NodeJS, with flexible find/filter/sortBy/difference methods and more.
The .push()
,.pop()
,.shift()
, and .unshift()
methods all mutate the list itself. All other methods (including sort methods) return a new copy of the list.
const List = require('@frctl/list');
const characters = new List([
{name: 'mickey', type: 'mouse', disney: true},
{name: 'jerry', type: 'mouse', disney: false},
{name: 'mighty', type: 'mouse', disney: false},
{name: 'pluto', type: 'dog', disney: true},
{name: 'odie', type: 'dog', disney: false},
]);
const mice = characters.filter('type', 'mouse');
const disneyDogs = characters.filter({
type: 'dog',
disney: true,
});
const mickey = characters.find(char => char.name === 'mickey');
const otherDogs = characters.difference(disneyDogs);
Install
npm i @frctl/list --save
Usage
Full API docs to come. For now see the tests for further usage info.
Install
Installation using Yarn is recommended.
yarn add @frctl/list
Requirements
List requires Node >= v6.0