Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

set-map

sindresorhus6MIT2.0.0

Map over a Set

set, map, es2015, iterator, iterate

readme

set-map

Map over a Set

Because Set is missing a Set#map method.

Install

$ npm install set-map

Usage

import setMap from 'set-map';

const set = new Set(['foo', 'bar']);

setMap(set, value => `yo${value}`).values();
//=> ['yofoo', 'yobar']

API

setMap(input, mapper)

input

Type: Set

The Set to map over.

mapper(element)

Type: function

Called for every element and should return the new element.