🔪 @iterable-iterator/slice
Iterable slicing functions for JavaScript. See docs.
⚠️ Depending on your environment, the code may requireregeneratorRuntime
to be defined, for instance by importing regenerator-runtime/runtime.
import {range} from '@iterable-iterator/range';
import {repeat} from '@iterable-iterator/repeat';
import {take, head, tail, trunc, drop} from '@iterable-iterator/slice'
take(range(10), 3); // 0 1 2
head(repeat("A"), 3); // A A A
tail(range(10), 3); // 7 8 9
trunc(range(10), 3); // 0 1 2 3 4 5 6
drop(range(10), 3); // 3 4 5 6 7 8 9
import {count} from '@iterable-iterator/count';
import {slice} from '@iterable-iterator/slice'
slice(count(), 40, 50, 3); // 40 43 46 49
import {le} from '@functional-abstraction/predicate';
import {takewhile, dropwhile} from '@iterable-iterator/slice'
takewhile(le(5), count()); // 0 1 2 3 4 5
dropwhile(le(5), count()); // 6 7 8 ...