Skip to content

GuMap proxies Map to provide dot accessor notation and immutability features.

License

Notifications You must be signed in to change notification settings

zachvictor/gu-map

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GuMap — 固Map

is strong, solid, and sure—an allusion to this class’s immutability-features.

What is GuMap? What does it do?
GuMap is a JavaScript class that extends the Map prototype to support dot accessor notation and immutability features. Unlike Map, GuMap can be configured to throw errors on state mutation.

What value does GuMap add?
Dot accessor notation is idiomatic and concise. Immutability can protect against unwanted state mutation. A Map that supports immutable properties may be able to serve compositional strategies that draw on functional programming patterns. Throwing an error on state mutation can help pinpoint logical errors quickly and prevent a mutated variable from "metastasizing" into a bigger problem.

How is GuMap implemented?
The GuMap class extends Map. Its constructor returns a Proxy, which is used to implement immutability, dot accessor notation for get and set, and "bridges" to standard Map properties. The GuMap class does not bridge Map[@@iterator]. Please use entries() instead.

What is the GuMapConfig class for?
The GuMapConfig class structures the parameter object of the GuMap constructor. It helps humans and machines "understand" the parameterization, the one for practical purposes, the other (typically) for static code analysis.

What’s in a name?
The name “GuMap” is a bilingual compound word, transliterating 固Map (gù-map) into Latin letters. 固 can mean strong, solid, and sure and is meant to allude to this class’s immutability-features. “Gu” is also intended playfully as a homophonic pun on “good” (English) or “gut” (German), daß diese Klasse fürund gut gehalten würde. The glyph 固 is found in Bronze Age sources and finds its modern form in Han Chinese with equivalents in Kanji and Hanja. For information, see the entry for 固 in Wiktionary.