Skip to content
wolfram77 edited this page Mar 27, 2020 · 29 revisions

Breaks iterable considering test as separator.

iterable.split(x, fn, [ths]);
// x:   an iterable
// fn:  test function (v, i, x)
// ths: this argument
// --> [...pieces]
const iterable = require('extra-iterable');

var x = [1, 2, 4, 5, 7, 8, 9];
iterable.split(x, v => v % 2===0);
  // [[1], [5, 7], [9]]

var x = [2, 4, 5, 6, 8];
iterable.split(x, v => v % 2===0);
// [[5]]

references

Clone this wiki locally