1.0.1 • Published 7 years ago

caldera-immutable-model v1.0.1

Weekly downloads
7
License
MIT
Repository
github
Last release
7 years ago

Immutable Model and Collection Classes

Immutable Model and Collection classes for node or web.

Installation

Use npm to install:

npm install caldera-immutable-model

Usage

The Model and Collection classes are data structures that wrap javascript objects and arrays, respectively.

Model

MethodDescription
toJS()Returns a plain javascript object representing the data
get(key: string) -> anyReturns the value for a key
set(key: string, value: any) -> ModelReturns a new Model with the key/value pair
remove(key: string) -> ModelReturns a new Model with the key/value removed
setIn(keyPath: [string], value: any) -> ModelReturns a new Model with the keyPath set
getIn(keyPath: [string]) -> anyReturns the value at the keyPath

Collection

MethodDescription
toJS()Returns a plain javascript object representing the data
get(index: number) -> anyReturns the value at an index
set(index: number, value: any) -> ModelReturns a new Collection with the index/value pair
push(value: any) -> ModelReturns a new Collection with the value pushed
toArray() -> [any]Returns a new Collection with the value pushed
remove(predicate) -> CollectionReturns a new Collection with any values removed where predicate returns true

Copyright and License

Code and documentation copyright 2017 Jon Brennecke. Code released under the MIT license. Docs released under Creative Commons.

1.0.1

7 years ago

1.0.0

7 years ago