This implements many array methods that are missing for Set
s, like map
, reduce
, and every
. It also adds some Set
-specific functions like intersection
. The complete list is in functions/
.
Almost everything is done with Set
operations. There are no conversions to arrays and back.
Install
npm install --save set-helpers
Use
Functions can be used as-is or added to the Set
prototype.
As-is:
const setHelpers = ;setHelpers;
Prototype:
extendPrototype: true ;1 2 3;
A combination of both:
const setHelpers = extendPrototype: true ;setHelpers;1 2 3;
Selectively extending the prototype:
extendPrototype: 'reduce' ;Setprototypereduce; // => [Function]Setprototypemap; // => undefined