Skip to content
wolfram77 edited this page Apr 13, 2020 · 25 revisions

Breaks array considering test as separator. 🏃 📼 📦 🌔

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

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

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

references

Clone this wiki locally