immutable-js/immutable-js

Pairwise aggregation or "buffer" operator for Iterables

Open

#400 ouverte le 19 mars 2015

Voir sur GitHub
 (2 commentaires) (0 réactions) (0 assignés)TypeScript (1 774 forks)batch import
enhancementhelp wanted

Métriques du dépôt

Stars
 (33 046 stars)
Métriques de merge PR
 (Merge moyen 12j 22h) (20 PRs mergées en 30 j)

Description

Hi, I really like Immutable.js.

I am used to use RxJS, and it's nice that many of its operators have counterparts in Immutable.js. But I feel one of them is missing, and that would be an operator that aggregates consecutive values for you. In Rx, that would be buffer or "pairwise" in RxJS, or even the good old scan, which is like reduce but used for producing an Iterable, instead of one single "reduced" value.

Practically, what I would like to do is:

> let a = Immutable.List([1,2,3,4,5]);
List [ 1, 2, 3, 4, 5 ]

> let b = a.pairwise();
List [ List[1,2], List[2,3], List[3,4], List[4,5] ]

Naive groupBy doesn't work for that because it doesn't overlap the children lists.

Guide contributeur