1.3.0 • Published 8 years ago
common-collections v1.3.0
Common Collections
This package is part of the Common Framework. It exposes collections and related interfaces that are mutually depended upon by other packages.
Installation
Install it from NPM:
npm install common-collections
Usage
Mapping
Use IMappable
to allow transformation of a collection's elements. Note that the map
method should return a new instance and not mutate the one it is called on.
class IMappable {
map(transformer) {}
}
Referencing
Use IReferenceable
to represent an instance that corresponds to a unique key in a collection. This key can be of any type and it is the user's responsibility to make sure that key types are consistent.
class IReferenceable {
reference() {}s
}
In the case where there may be either a primitive or a referenceable instance (such as an argument to a method), use the resolveReference(reference)
method to return either the primitive or the reference's unique key.