const result1 = from([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).pipe(
chunkByAccumulation(
0,
(acc, current) => acc + current,
(acc) => acc <= 10
)
).toArray();
// result1: [[1, 2, 3, 4], [5], [6], [7], [8], [9], [10]]
// Example where the first value doesn't satisfy the condition
const result2 = from([11, 1, 2, 3]).pipe(
chunkByAccumulation(
0,
(acc, current) => acc + current,
(acc) => acc <= 10
)
).toArray();
// result2: []
// Example where enumeration stops when a single value doesn't satisfy the condition
const result3 = from([1, 2, 3, 15, 4, 5]).pipe(
chunkByAccumulation(
0,
(acc, current) => acc + current,
(acc) => acc <= 10
)
).toArray();
// result3: [[1, 2, 3]]