trait

trait

Source:

Lib­rary for ad­vanced type level pro­gram­ming in JS.

See the trait class.

The traits in this file usu­ally are im­ple­men­ted for at least: Plain Ob­ject, Map, Set, Ar­ray, String

Laws

These ap­ply to all traits in this class.

  • Ar­rays, Strings and any list-like data struc­tures are treated as map­pings from in­dex -> value
  • Ar­ray sparse­ness is ig­nored on read; any list-like con­tainer has a spe­cific in­dex if size(my­Con­tainer) => key; get­ting an un­set value yields un­defined
  • Sets are treated as map­pings from a key to it­self