Record
Index
Accessor
get
Return an Option of value for the given
keyconst record = { myProperty: 'myValue' };Record.get(record, 'myProperty'); // Option.Some('myValue')Record.get(record, 'nonExistent'); // Option.None
size
Return the number of entries in the record
const record = { first: 1, second: 2 };Record.size(record); // 2
Constructor
empty
Return an empty Record
const empty = Record.empty(); // frozen {}
from
Return a new Record from an iterable of [key, value]
const record = Record.from([['a', 1], ['b', 2]]); // frozen { a: 1, b: 2}
Other
delete
Return a new record without the
keyconst record = { myProperty: 'myValue' };Record.delete(record, 'myProperty'); // {}
entries
Return an iterator over all [key, value]
const record = { first: 1, second: 2 };Array.from(Record.entries(record)); // [['first', 1], ['second', 2]]
forEach
Call
fn(value, key, record)on each entries in the recordconst record = { first: 1, second: 2 };Record.forEach(record, (value, key, record) => {// call (1, 'first', record)// call (2, 'second', record)}); // 2
has
Return true if
recordcontainskeyconst record = { myProperty: 'myValue' };Record.has(record, 'myProperty'); // trueRecord.has(record, 'nonExistent'); // false
keys
Return an iterator over all keys
const record = { first: 1, second: 2 };Array.from(Record.keys(record)); // ['first', 'second']
set
Return a new record including the new
[key, value]const record = { myProperty: 'myValue' };Record.set(record, 'myOtherProperty', 'myOtherValue'); // { myProperty: 'myValue', myOtherProperty: 'myOtherValue' }
values
Return an iterator over all values
const record = { first: 1, second: 2 };Array.from(Record.entries(record)); // [1, 2]
A collection of functions to manipulate Record