1.0.1 • Published 3 years ago

set-enhance v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

set-enhance

This library extends JS Set prototype with methods like map(), reduce() and others.

Those methods work just like the similiarly named Array methods.

List of added methods:

  • any (Array.some() counterpart)
  • every
  • filter
  • join
  • map
  • reduce
  • reduceRight
  • toString

This library also includes TypeScript definitions, to use those import and use function newSet for creating new Set instances (recommended) or import EnhancedSet type definition and assert it on to regular Set instances:

import { newSet } from "set-enhance";

const mySet = newSet([1, 2, 3]);
// const mySet: EnhancedSet<number, Set<number>>

or

import { EnhancedSet } from "set-enhance";
const mySet: EnhancedSet<number> = new Set([1, 2, 3]) as any;
// const mySet: EnhancedSet<number, Set<number>>