Model and Collection classes based on Immutable.js
Immutable Model
and Collection
classes for node or web.
Use npm to install:
npm install caldera-immutable-model
The Model
and Collection
classes are data structures that wrap javascript objects and arrays, respectively.
Method | Description |
---|---|
toJS() |
Returns a plain javascript object representing the data |
get(key: string) -> any |
Returns the value for a key |
set(key: string, value: any) -> Model |
Returns a new Model with the key/value pair |
remove(key: string) -> Model |
Returns a new Model with the key/value removed |
setIn(keyPath: [string], value: any) -> Model |
Returns a new Model with the keyPath set |
getIn(keyPath: [string]) -> any |
Returns the value at the keyPath |
Method | Description |
---|---|
toJS() |
Returns a plain javascript object representing the data |
get(index: number) -> any |
Returns the value at an index |
set(index: number, value: any) -> Model |
Returns a new Collection with the index/value pair |
push(value: any) -> Model |
Returns a new Collection with the value pushed |
toArray() -> [any] |
Returns a new Collection with the value pushed |
remove(predicate) -> Collection |
Returns a new Collection with any values removed where predicate returns true |
Code and documentation copyright 2017 Jon Brennecke. Code released under the MIT license. Docs released under Creative Commons.