@sugarcoated/fondant-dictionary
v1.0.4
Published
Typed Collection.
Downloads
7
Readme
Dictionary
extends Collection
to bring typed Collection
s to JavaScript's weakly typed enviroment. Built to ignore primitives or convert them into Object
s.
API Reference
new Dictionary(type, [initial])
Creates a Dictionary
instance.
type
is the non-primitiveconstructor
symbol reference to mark. For example, if I created aclass
calledBook
, then I would pass inBook
, not an instance.initial
is the initialiser to be passed to the encapsulatedCollection
, expected asArray.<Array.<String, Book>>
.class Book { constructor (bookName) { this.bookName = bookName; } } new Dictionary(Book); new Dictionary(Book, [['one', new Book('one')]]);
For more details on how this constructor
works, see Collection#constructor.
.set(name, value)
Overrides Collection
's method (which can be read about here).
name
is expected as aString
, identifying the name/key that will identify the particular pair.value
is expected as theObject
you passed to theconstructor
initially; for the purpose of example this wasBook
in our case.const myDictionary = new Dictionary(Book); myDictionary.set('one', new Book('one'));
.map(condition, [binding])
Overrides Collection
's method (which can be read about here to reset item caches.