SetFP
Set
object with native filter
, map
,reduce
, every
, and some
methods. Zero Dependencies.
https://www.npmjs.com/package/setfp
Motivation
Sets don’t have these methods natively. One would first need to copy an iterator into an array [...iterator]
before using .map
, .filter
, .reduce
, every
and some
. SetFP allows you to use those methods natively.
Installation
npm install setfp
OR
yarn add setfp
Initialize
Javascript
const SetFP = default;const test = 0 1 2 3;
TypeScript
; // Diamond notation needed if no arguments are provided; // OR with arguments, types are inferred.;
Usage
const filterSetToSet = test;SetFP Set 1 2 3 const filterSetToArray = test; 1 2 3 const mapSetToSet = test;SetFP Set 0 2 4 6 const mapSetToArray = test; 0 2 4 6 const reduce = test;6 const every = test;false const some = test;true