Aller au contenu principal

Record

A collection of functions to manipulate Record

Index

Accessor

get

  • get<Key, Value>(self, key): Option<Value>
  • Return an Option of value for the given key

    @example
    const record = { myProperty: 'myValue' };
    Record.get(record, 'myProperty'); // Option.Some('myValue')
    Record.get(record, 'nonExistent'); // Option.None

size

  • size<D>(self): Int
  • Return the number of entries in the record

    @example
    const record = { first: 1, second: 2 };
    Record.size(record); // 2

Constructor

empty

  • empty<Key, Value>(): Record<Key, Value>
  • Return an empty Record

    @example
    const empty = Record.empty(); // frozen {}

from

  • from<Key, Value>(iterable): Record<Key, Value>
  • Return a new Record from an iterable of [key, value]

    @example
    const record = Record.from([['a', 1], ['b', 2]]); // frozen { a: 1, b: 2}

Other

delete

  • delete<Key, Value>(self, key): Record<Key, Value>
  • Return a new record without the key

    @example
    const record = { myProperty: 'myValue' };
    Record.delete(record, 'myProperty'); // {}

entries

  • entries<Key, Value>(self): Iterable<[Key, Value]>
  • Return an iterator over all [key, value]

    @example
    const record = { first: 1, second: 2 };
    Array.from(Record.entries(record)); // [['first', 1], ['second', 2]]

forEach

  • forEach<Key, Value, D>(self, fn): void
  • Call fn(value, key, record) on each entries in the record

    @example
    const record = { first: 1, second: 2 };
    Record.forEach(record, (value, key, record) => {
    // call (1, 'first', record)
    // call (2, 'second', record)
    }); // 2

has

  • has<Key>(self, key): boolean
  • Return true if record contains key

    @example
    const record = { myProperty: 'myValue' };
    Record.has(record, 'myProperty'); // true
    Record.has(record, 'nonExistent'); // false

keys

  • keys<Key>(self): Iterable<Key>
  • Return an iterator over all keys

    @example
    const record = { first: 1, second: 2 };
    Array.from(Record.keys(record)); // ['first', 'second']

set

  • set<Key, Value>(self, key, value): Record<Key, Value>
  • Return a new record including the new [key, value]

    @example
    const record = { myProperty: 'myValue' };
    Record.set(record, 'myOtherProperty', 'myOtherValue'); // { myProperty: 'myValue', myOtherProperty: 'myOtherValue' }

values

  • values<Key, Value>(self): Iterable<Value>
  • Return an iterator over all values

    @example
    const record = { first: 1, second: 2 };
    Array.from(Record.entries(record)); // [1, 2]