Skip to content

Map, WeakMap, Set, and WeakSet extends with either `set(key, value)` or `add(value)` that returns the value.

License

Notifications You must be signed in to change notification settings

WebReflection/dsm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Direct Set / Map

build status Coverage Status

This module simply exports Map, WeakMap, Set, and WeakSet extends with either set(key, value) or add(value) that returns the value itself, instead of the map or set.

import {Map, WeakMap, Set, WeakSet} from '@webreflection/dsm';

const obj = {};
console.assert((new Map).set('key', 1) === 1);
console.assert((new WeakMap).set(obj, 2) === 2);
console.assert((new Set).add(3) === 3);
console.assert((new WeakSet).add(obj) === obj);

About

Map, WeakMap, Set, and WeakSet extends with either `set(key, value)` or `add(value)` that returns the value.

Resources

License

Stars

Watchers

Forks

Packages

No packages published