MaFP
Map
object with native filter
, map
,reduce
, every
, and some
methods. Zero Dependencies.
https://www.npmjs.com/package/mafp
Motivation
Maps don’t have these methods natively. One would first need to copy an iterator into an array [...iterator]
before using .map
, .filter
, .reduce
. MaFP allows you to use those methods natively.
Installation
npm install mafp
OR
yarn add mafp
Initialize
Javascript
const MaFP = default;const test = "A" true "B" false "C" true "D" true;
TypeScript
; // Diamond notation needed if no arguments are provided; // OR with arguments, types are inferred.;
Usage
test;// MaFP [Map] { 'A' => true, 'C' => true, 'D' => true } test;// [ 'A', true ], [ 'C', true ], [ 'D', true ] ] test;// MaFP [Map] { 'A' => false, 'B' => true, 'C' => false, 'D' => false } test;// [ [ 'A', false ], [ 'B', true ], [ 'C', false ], [ 'D', false ] ] test;// 3 test;// false test;// true
Also works with .keys()
and .values()
:
test;// [ 'A', 'C', 'D' ] // ETC...