Skip to content

hoomanlogic/those

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

those

npm version

Non-destructive syntactic sugar for arrays and object maps

Installing

npm install --save @hoomanlogic/those

Basic Usage

import those from '@hoomanlogic/those';

var people = [{ name: 'Alayna', age: 9 }, { name: 'Braylon', age: 6 }, { name: 'David', age: 35}];

// Get the first person with the name 'Braylon'
those(people).first({ name: 'Braylon'});

// Get the youngest person
var youngest = those(people).order('age').first(); 

// Pop the oldest person out of the array and assign to variable
var oldest;
those(people).order('age').flip().flick(undefined, function (flicked) { oldest = flicked });

// Check if the youngest is in the array
those(people).has(youngest); // true
 
// Check if the oldest is in the array
those(people).has(oldest); // false

// Toggle an item in a list (add if it doesn't exist, remove if it does)
those(people).toggle(oldest);
those(people).has(oldest); // true
those(people).toggle(oldest);
those(people).has(oldest); // false

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published