Pairs

stdtraits~ Pairs

Source:

Get an iter­ator over a con­tainer.

const {list, val­ues, keys, pairs, Pairs} = re­quire('fer­rum');
class Bar {
  *[Pairs.sym]() {
    yield ['foo', 42];
    yield ['bar', 5];
  }
}

list(pairs(new Bar()); // => [['foo', 42], ['bar', 5]]
list(keys(new Bar()); // => ['foo', 'bar']
list(val­ues(new Bar()); // => [42, 5]

This is dif­fer­ent from the Se­quence trait in se­quence.js in that this al­ways re­turns pairs, even for lists, sets, strings...

In­ter­face

(c: Con­tainer(k: Key, v: Value)) => r: Se­quence([k: Key, v: Value], ...).

Spe­cial­iz­a­tion Notes

Ar­ray like types re­turn in­dex => value, set re­turns value => value.

See: pairs See: keys See: val­ues