0.0.5 • Published 8 years ago
@nathanfaucett/immutable-record v0.0.5
Immutable Record
Immutable persistent record for the browser and node.js
Install using npm
$ npm install @nathanfaucett/immutable-record --saveInstall using yarn
$ yarn add @nathanfaucett/immutable-record --saveExample Usage
var ImmutableRecord = require("@nathanfaucett/immutable-record");
var User = ImmutableRecord({
id: 0,
name: null
}, "User");
var user = new User({
id: 1,
name: "username"
});Docs
Members
length -> Number
returns size of Record, only available if Object.defineProperty is supportedStatic Functions
Record.isRecord(value: Any) -> Boolean
returns true if value is a hash map else falseRecord.of(...values: Array) -> Record
creates Record from passed values same as new Record(...values: Array<Any>)Record.equal(a: Record, b: Record) -> Boolean
compares hash maps by valuesFunctions
size() -> Number
returns size of Recordget(key: Any) -> Any
returns value at keyhas(key: Any) -> Boolean
returns true if hash map contains keyset(key: Any, value: Any) -> Record
returns new Record if value at key is not set or differentremove(key: Any) -> Record
returns new Record without the value at keyiterator(reverse = false: Boolean) -> Iterator
returns IteratortoArray() -> Array<Any, Any>
returns Record elements in an ArraytoObject() -> Object<String, Any>
returns Record elements in an Object, keys should be primitives or some key value pairs will be lostjoin(separator = " ") -> String
join all elements of an Record into a StringtoString() -> String
String representation of Recordequals(other: Record) -> Boolean
compares this hash map to other hash map by valuesevery, filter, forEach, forEachRight, map, reduce, reduceRight, some
some common methods