@sugarcoated/fondant-dictionary
v1.0.4
Published
Typed Collection.
Readme
Dictionary extends Collection to bring typed Collections to JavaScript's weakly typed enviroment. Built to ignore primitives or convert them into Objects.
API Reference
new Dictionary(type, [initial])
Creates a Dictionary instance.
typeis the non-primitiveconstructorsymbol reference to mark. For example, if I created aclasscalledBook, then I would pass inBook, not an instance.initialis 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).
nameis expected as aString, identifying the name/key that will identify the particular pair.valueis expected as theObjectyou passed to theconstructorinitially; for the purpose of example this wasBookin 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.
