Like a regular array, a set can store many items. However, duplicate items are ignored - it
only keeps unique items. ixfx's Sets.ISetMutable allows for considering items as identical by value, not
just by reference as the default JS Set operates
Maps.ExpiringMap has the same semantics as a regular map, but can automatically remove items if they haven't been set/get for a given interval, and/or if a capacity limit is reached.
Maps.IMapOf allows for several values to be stored under a single key. Unlike a regular JS Map
which only allows a single value per key. IMapOfMutable also has events for listening to changes
in the data.
For cases where events are not needed consider Maps.mapOfSimpleMutable. This is a bit more lightweight.
Example: Importing
// If library is stored two directories up under `ixfx/` import {map} from'../../ixfx/dist/collections.js'; // Import from web import {map} from'https://unpkg.com/ixfx/dist/collections.js'
This module includes a variety of techniques for storing and retrieving data.
Helper functions for working with in-built Javascript collections
MutableSet
Like a regular array, a set can store many items. However, duplicate items are ignored - it only keeps unique items. ixfx's Sets.ISetMutable allows for considering items as identical by value, not just by reference as the default JS Set operates
CircularArray
circularArray extends a regular array, but only keeps the last x number of items.
Ordered collections
Queues: a list of ordered data, like a bakery queue
Stacks: a list of ordered data, like a stack of plates
Both queue and stack come in mutable and immutable varieties and can limit items stored in varies ways.
Map
Maps.IMapImmutable is a slight variant of the usual JS Map. It allows for a custom logic for computing keys for items based on a function.
Maps.ExpiringMap has the same semantics as a regular map, but can automatically remove items if they haven't been set/get for a given interval, and/or if a capacity limit is reached.
Map-of
Maps.IMapOf allows for several values to be stored under a single key. Unlike a regular JS Map which only allows a single value per key. IMapOfMutable also has events for listening to changes in the data.
For cases where events are not needed consider Maps.mapOfSimpleMutable. This is a bit more lightweight.
Example: Importing