Skip to content

Latest commit

 

History

History
2112 lines (1488 loc) · 44.5 KB

API.md

File metadata and controls

2112 lines (1488 loc) · 44.5 KB

API

Function

apply

  • (f, iterable) => f(...iterable)
  • source
const args = [10, 20];
add(...args); // 30
apply(add, args); // 30
apply(add)(args); // 30

applyEach

  • ([f], args) => [f(...args)]
  • ({k: f}, args) => {k: f(...args)}
  • source
const args = [2, 3, 4];
const addAll = (a, b, c) => a + b + c;
const multiplyAll = (a, b, c) => a * b * c;

addAll(...args) // 9
multiplyAll(...args) // 24

applyEach([addAll, multiplyAll], args) // [9, 24]
applyEach({ add: addAll, mul: multiplyAll }, args) // { add: 9, mul: 24 }

applyMethod

  • (String k, { k: v }, args) => v(...args)
  • String k => ({ k: v }, args) => v(...args)
  • source
applyMethod('add', { add: (a, b, c = 0) => a + b + c }, [1, 2]) // 3
applyMethod('add', { add: (a, b, c = 0) => a + b + c }, [1, 2, 3]) // 6
applyMethod('add')({ add: (a, b, c = 0) => a + b + c }, [1, 2, 3]) // 6

bindMethod

call

  • (f, ...args) => f(...args)
  • source
add(10, 20); // 30
call(add, 10, 20); // 30
call(add)(10, 20); // 30

callEach

  • ([(a, b) => c, (a, b) => d, ...], a, b) => [c, d, ...]
  • ([(a, b) => Promise c, (a, b) => Promise d, ...], a, b) => Promise [c, d]
  • ({ k: (a, b) => c, k2: (a, b) => d }, a, b) => { k: c, k2: d }
  • ({ k: (a, b) => Promise c, k2: (a, b) => Promise d }, a, b) => Promise { k: c, k2: d }
  • source
callEach([(a) => a + 1, (a) => a + 2], 10);
// [11, 12]

callEach(
  {
    a: (a) => a + 1,
    b: (a) => a + 2,
  },
  10
);
// {a: 11, b: 12}

callEach([
  (_) => Promise.resolve(1),
  (_) => Promise.resolve(2),
  (_) => Promise.resolve(3),
]).then(log);
// [1, 2, 3]

callEach({
  a: (_) => Promise.resolve(1),
  b: (_) => Promise.resolve(2),
  c: (_) => Promise.resolve(3),
}).then(log);
// {a: 1, b: 2, c: 3}

callMethod

constant

const a = constant("A");
a(); // A
a(); // A

curry

  • ((a, b, ...) => e) => a => (b, ...) => e
  • ((a, b, ...) => e) => (a, b, ...) => e
  • source
const add = curry((a, b) => a + b);

const add10 = add(10);
add10(5); // 15
add10(6); // 16

add(10, 5); // 15

curryN

const addAll = (...args) => args.reduce((a, b) => a + b);

const add1 = curryN(1, addAll);
log(add1(1)(2)); // 3
log(add1(1, 2)); // 3
// add1(1)(2)(3) => error!

const add2 = curryN(2, addAll);
log(add2(1)(2)(3)); // 6
log(add2(1, 2)(3)); // 6
log(add2(1)(2, 3)); // 6
log(add2(1, 2, 3)); // 6
// add2(1)(2)(3)(4); => error!

debounce

  • (f, time) => (...args) =>
  • source

go

  • (a, a => b, b => c, ..., y => z) => z
  • (Promise a, a => b, b => c, ..., y => z) => Promise z
  • (a, a => Promise b, b => Promise c, ..., y => z) => Promise z
  • source
go(
  0,
  (a) => a + 1,
  (a) => a + 10,
  log
); // 11

go(
  0,
  (a) => Promise.resolve(a + 1),
  (a) => a + 10,
  log
); // 11

const b = go(
  0,
  (a) => a + 1,
  (a) => a + 10
);
log(b); // 11

const pb = go(
  0,
  (a) => Promise.resolve(a + 1),
  (a) => a + 10
);
pb.then(log); // 11

juxt

  • (f, f2, f3, ...) => (...args) => [f(...args), f2(...args), f3(...args), ...]
  • source
const compute = juxt(min, max, sum, mean);
log(...compute([1, 2, 3, 4, 5])); // 1, 5, 15, 3

negate

const a = negate((a) => a);
log(a(true)); // false
log(a(false)); // true

once

const f = once((a) => a + 10);
log(f(5)); // 15
log(f(5)); // 15

pipe

  • ((a, b, ...) => d, d => e, ..., y => z) => (a, b, ...) => z
  • ((a, b, ...) => Promise d, d => e, e => Promise f, ..., y => z) => (a, b, ...) => Promise z
  • source
const f1 = pipe(
  (a) => a.toUpperCase(),
  (a) => a == "A"
);
const b = f1("a");
log(b); // true

const total = (f) =>
  pipe(
    map(f),
    reduce((a, b) => a + b)
  );

const totalAge = total(({ age }) => age);

go(fetchUsers(), totalAge, log);
// 186

go(
  fetchProducts(),
  total(({ price }) => price),
  log
);
// 156000

tap

  • (g, f, ...) => a => go(a, g, f, ..., _ => a)
  • source
go(
  10,
  (a) => a + 5,
  tap((a) => a + 5, log), // 20
  (a) => a + 10,
  log
); // 25

throttle

Strict

add

  • Number => Number => Number
  • source
add(10, 5);
// 15

add(10)(5);
// 15

append

baseSel

const sel = baseSel(".");
sel("a.b", { a: { b: 10 } });
// 10

sel("a.b", { b: { c: 20 } });
// undefined

const sel2 = baseSel(">");
sel2("a>b", { a: { b: 10 } });
// 10

sel2("a>b", { b: { c: 20 } });
// undefined

blockUntilSettled

// useful for functions to block multiple calls

const callApi = blockUntilSettled(() => {
  console.log('called!');
  return delay(100, 5);
});

(async function () {
  const p1 = callApi(); // console - called!
  console.log('after p1'); // console - after p1
  const p2 = callApi(); // 
  console.log('after p2'); // console - after p2
  const p3 = callApi(); // 
  console.log('after p3'); // console - after p3
  const [r1, r2, r3] = await Promise.all([p1, p2, p3]);

  const r4 = await callApi(); // console - called!

  console.log(r1, r2, r3, r4); // 5, undefined, undefined, 5
  
})();

chunk

chunk(2, [1, 2, 3, 4, 5]);
// [[1, 2], [3, 4], [5]]

clone

compact

  • Iterable a => [a]
  • Iterable Promise a => Promise [a]
  • source
compact([1, 2, 0, false, true, null]);
// [1, 2, true]

countBy

  • (a => b) => Iterable a => { [b]: n }
  • (a => b) => Iterable Promise a => Promise { [b]: n }
  • (a => Promise b) => Iterable a => Promise { [b]: n }
  • (a => Promise b) => Iterable Promise a => Promise { [b]: n }
  • source
countBy((a) => (a % 2 ? "odd" : "even"), [1, 2, 3, 4, 5]);
// { odd: 3, even: 2 }

deepFlat

  • [[[[a]]]] => [a]
  • Iterable Iterable Iterable ... Iterable a => [a]
  • [Promise [[Promise a]]] => Promise [a]
  • [Promise [[Iterable Promise a]]] => Promise [a]
  • source
deepFlat([[1, 2, [3, [4, 5, [6], [[7]]]]]]);
// [1, 2, 3, 4, 5, 6, 7];

defaults

  • ({}, {}, ..., {}) => {}
  • source
defaults({ flavor: "chocolate" }, { flavor: "vanilla", sprinkles: "lots" });
// {flavor: "chocolate", sprinkles: "lots"}

defaultTo

const obj = { a: 1, c: null, d: NaN };
defaultTo(0, obj.a);
// 1
defaultTo(0, obj.b);
// 0
defaultTo(0, obj.c);
// 0
defaultTo(0, obj.d);
// 0

delay

  • time => a => Promise a
  • (time, a) => Promise a
  • source
go("hi", delay(1000), log); // After 1 second "hi"

difference

difference([2, 3], [2, 1]);
// [1]
difference([2, 2, 2, 2], [1, 1, 1, 1, 1]);
// [1, 1, 1, 1, 1]
difference([1, 2, 3, 4], [1]);
// []
difference([2], [1, 2, 3, 4]);
// [1, 3, 4]

differenceBy

differenceBy((a) => a.x, [{ x: 1 }], [{ x: 2 }, { x: 1 }]);
// [{ x: 2 }]

differenceWith

const cmp = (x, y) => x.a === y.a;
const l1 = [{ a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }, { a: 5 }];
const l2 = [{ a: 3 }, { a: 4 }];
differenceWith(cmp, l1, l2);
// [{a: 1}, {a: 2}, {a: 5}]

divide

divide(4, 2) // 2
divide(4)(2) // 2

drop

drop([1, 2, 3, 4]);
// [2, 3, 4]

dropRight

dropRight([1, 2, 3, 4]);
// [1, 2, 3]

dropUntil

dropUntil((a) => a > 1, [1, 2, 3, 4]);
// [3, 4]

dropWhile

dropWhile((a) => a < 3, [1, 2, 3, 4]);
// [3, 4]

each

  • (a => b) => Iterable a => [a]
  • (a => b) => Iterable Promise a => Promise [a]
  • (a => Promise b) => Iterable a => Promise [a]
  • (a => Promise b) => Iterable Promise a => Promise [a]
  • source
go(
  document.querySelectorAll(".post"),
  each((el) => (el.innerHTML = "")),
  log
); // [div.post, div.post, div.post];

entries

entries({ a: 1, b: 2, c: 3 });
// [['a', 1], ['b', 2], ['c', 3]]

extend

  • ({}, {}, ..., {}) => {}
  • source
extend({ flavor: "vanilla", sprinkles: "lots" }, { flavor: "chocolate" });
// {flavor: "chocolate", sprinkles: "lots"}

extendRight

  • ({}, {}, ..., {}) => {}
  • source
extendRight({ flavor: "vanilla", sprinkles: "lots" }, { flavor: "chocolate" });
// {flavor: "vanilla", sprinkles: "lots"}

filter

  • (a => Boolean) => Iterable a => [a]
  • (a => Boolean) => Iterable Promise a => Promise [a]
  • (a => Promise Boolean) => Iterable a => Promise [a]
  • (a => Promise Boolean) => Iterable Promise a => Promise [a]
  • source
filter((a) => a % 2, [1, 2, 3]);
// [1, 3]

filter((a) => a % 2, [
  Promise.resolve(1),
  Promise.resolve(2),
  Promise.resolve(3),
]).then(log);
// [1, 3]

filter((a) => Promise.resolve(a % 2), [1, 2, 3]).then(log);
// [1, 3]

filter((a) => Promise.resolve(a % 2), [
  Promise.resolve(1),
  Promise.resolve(2),
  Promise.resolve(3),
]).then(log);
// [1, 3]

find

  • find = head . L.filter
  • (a => Boolean) => Iterable a => a
  • (a => Promise Boolean) => Iterable a => Promise a
  • (a => Boolean) => Iterable Promise a => Promise a
  • (a => Promise Boolean) => Iterable Promise a => Promise a
  • source
find(a => a > 3, [1, 2, 3, 4, 5]);
// 4

find(({age}) => age == 23, [
  { name: 'a', age: 15, ... },
  { name: 'b', age: 19, ... },
  { name: 'c', age: 23, ... },
  { name: 'd', age: 17, ... },
  { name: 'e', age: 23, ... }
]);
// { name: 'c', age: 23, ... }

findWhere

  • {k: v} => Iterable {k: v} => {k: v}
  • {k: v} => Iterable Promise {k: v} => Promise {k: v}
  • source
findWhere({ age: 23 }, [
  { name: 'a', age: 15, ... },
  { name: 'b', age: 19, ... },
  { name: 'c', age: 23, ... },
  { name: 'd', age: 17, ... },
  { name: 'e', age: 23, ... }
]);
// { name: 'c', age: 23, ... }

findWhere({ name: 'e', age: 23 }, [
  { name: 'a', age: 15, ... },
  { name: 'b', age: 19, ... },
  { name: 'c', age: 23, ... },
  { name: 'd', age: 17, ... },
  { name: 'e', age: 23, ... }
]);
// { name: 'e', age: 23, ... }

flat

  • (Iterable Iterable a, Number depth) => [a]
  • (Iterable Promise Iterable a, Number depth) => Promise [a]
  • (Iterable Iterable Promise a, Number depth) => Promise [a]
  • source
flat([[1, 2], [3, 4]]);
// [1, 2, 3, 4]

flat([[1, [2]],[[[3]]]]);
// [1, [2], [[3]]];

flat([[1, [2]], [[[3]]]], 2);
// [1, 2, [3]];

flat([[1, [2]], [[[3]]]], 3);
// [1, 2, 3];

await flat([Promise.resolve([1, 2]), [Promise.resolve(3), 4]]);
// [1, 2, 3, 4]

flatMap

  • flatMap = flat . mapLazy
  • (a => Iterable b) => Iterable a => [b]
  • (a => Iterable b) => Iterable Promise a => Promise [b]
  • (a => Iterable Promise b) => Iterable a => Promise [b]
  • (a => Promise Iterable b) => Iterable Promise a => Promise [b]
  • (a => Promise Iterable Promise b) => Iterable a => Promise [b]
  • (a => Promise Iterable Promise b) => Iterable Promise a => Promise [b]
  • source
flatMap((a) => range(a), [1, 2]);
// [0, 0, 1]

await flatMap((a) => Promise.resolve(range(a)), [1, 2]);
// [0, 0, 1]

fork

groupBy

groupBy((a) => (a % 2 ? "odd" : "even"), [1, 2, 3, 4, 5]);
// { odd: [1, 3, 5], even: [2, 4] }

head

head([1, 2, 3, 4]);
// 1

identity

const identity = (a) => a;

includes

indexBy

const products = [
  { id: 1, price: 100 },
  { id: 3, price: 100 },
  { id: 5, price: 100 },
];
indexBy((p) => p.id, products);
// {1: {id: 1, price: 100}, 3: {id: 3, price: 100}, 5: {id: 5, price: 100}}

initial

initial([1, 2, 3]);
// [1, 2]

insert

  • (Number a, b, Array c) => Array d
  • source
// prepend
insert(-1, 0, [1, 2, 3]) // [0, 1, 2, 3]
insert(0, 0, [1, 2, 3]) // [0, 1, 2, 3]

// middle
insert(2, 2.5, [1, 2, 3]) // [1, 2, 2.5, 3]

// append
insert(3, 4, [1, 2, 3]) // [1, 2, 3, 4]
insert(100, 4, [1, 2, 3]) // [1, 2, 3, 4]

intersection

intersection([2, 1], [2, 3]);
// [2]
intersection([1, 2, 1, 1, 3], [1, 1, 1, 2, 4]);
// [1, 2]

intersectionBy

intersectionBy((o) => o.x, [{ x: 2 }, { x: 1 }], [{ x: 1 }]);
// [{ x: 1 }]

intersectionWith

const cmp = (x, y) => x.a === y.a;
const l1 = [{ a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }, { a: 5 }];
const l2 = [{ a: 3 }, { a: 4 }];
intersectionWith(cmp, l1, l2);
// [{a: 3}, {a: 4}]

invert

invertBy

keys

keys({ a: 1, b: 2, c: 3 });
// ['a', 'b', 'c']

last

last([1, 2, 3]);
// 3

map

  • (a => b) => Iterable a => [b]
  • (a => b) => Iterable Promise a => Promise [b]
  • (a => Promise b) => Iterable a => Promise [b]
  • (a => Promise b) => Iterable Promise a => Promise [b]
  • source
map((a) => a + 10, [1, 2, 3]);
// [11, 12, 13]

map((a) => Promise.resolve(a + 10), [1, 2, 3]).then(log);
// [11, 12, 13]

map((a) => a.nodeName, document.querySelectorAll("head *"));
// ["META", "TITLE", "SCRIPT"]

map(
  (a) => a + 10,
  (function* () {
    yield 4;
    yield 5;
  })()
);
// [14, 15]

mapEntries

  • (a => b) => Iterable [k, a] => [[k, b]]
  • (a => b) => Iterable [k, Promise a] => Promise [[k, b]]
  • (a => Promise b) => Iterable [k, a] => Promise [[k, b]]
  • (a => Promise b) => Iterable [k, Promise a] => Promise [[k, b]]
  • source
mapEntries((a) => a + 10, [
  ["a", 1],
  ["b", 2],
]);
// [['a', 11], ['b', 12]]

mapEntries((a) => Promise.resolve(a + 10), [
  ["a", 1],
  ["b", 2],
]).then(log);
// [['a', 11], ['b', 12]]

// entries == Object.entries
// object == Object.fromEntries
object(mapEntries((a) => a + 10, entries({ a: 1, b: 2 })));
// { a: 11, b: 12 }

go(
  { a: 1, b: 2 },
  entries,
  mapEntries((a) => Promise.resolve(a + 10)),
  object
).then(log);
// { a: 11, b: 12 }

mapObject

  • (a => b) => { k: a } => { k: b }
  • (a => b) => { k: Promise a } => Promise { k: b }
  • (a => Promise b) => { k: a } => Promise { k: b }
  • (a => Promise b) => { k: Promise a } => Promise { k: b }
  • source
mapObject((a) => a + 10, { a: 1, b: 2 });
// { a: 11, b: 12 }

mapObject((a) => Promise.resolve(a + 10), { a: 1, b: 2 }).then(log);
// { a: 11, b: 12 }

go(
  { a: 1, b: 2 },
  mapObject((a) => Promise.resolve(a + 10)),
  log
);
// { a: 11, b: 12 }

max

max([1, 3, 7, 4]);
// 7

maxBy

maxBy((a) => a * -1, [1, 3, 7, 4]);
// 1

mean

mean([1, 2, 3, 4, 5, 6]) // 3
mean(L.range(1, 6)) // 3
await mean(Promise.resolve([1, 2, 3, 4, 5, 6])) // 3

meanBy

meanBy(identity, [1, 2, 3, 4, 5, 6]) // 3
meanBy(
  sel('age'),
  [{ age: 10 }, { age: 20 }, { age: 30 }, { age: 40 }, { age: 50 }, { age: 60 }]
)
// 35

min

min([1, 3, 7, 4]);
// 1

minBy

minBy((a) => a * -1, [1, 3, 7, 4]);
// 7

noop

function noop() {}

object

object([
  ["a", 1],
  ["b", 2],
  ["c", 3],
]);
// {a: 1, b: 2, c: 3}

omit

  • ([], {}) => {}
  • (keys, object) => object without input keys
  • source
omit(["a, c"], { a: 1, b: 2, c: 3, d: 4 });
// {b: 2, d: 4}

omitBy

  • omitBy <-> pickBy
  • (f, {}) => {}
  • source
omitBy(([k]) => ['a', 'b'].includes(k), { a: 1, b: 2, c: 3, d: 4 });
// {b: 2, d: 4}

omitBy(([k, v]) => v % 2 === 0, { a: 1, b: 2, c: 3, d: 4 });
// {a: 1, c: 3}

partition

partition((a) => a % 2, [1, 2, 3, 4, 5]);
// [[1, 3, 5], [2, 4]]

pick

pick(["a, c"], { a: 1, b: 2, c: 3, d: 4 });
// {a: 1, c: 3}

pickBy

  • pickBy <-> omitBy
  • (f, {}) => {}
  • source
pickBy(([k, v]) => ['a', 'c'].includes(k), { a: 1, b: 2, c: 3, d: 4 });
// {a: 1, c: 3}

pickBy(([k, v]) => v % 2 === 0, { a: 1, b: 2, c: 3, d: 4 });
// {b: 2, d: 4}

pluck

  • String k => Iterable a => [a[k]]
  • String k => Iterable Promise a => Promise [a[k]]
  • source
pluck("id", [{ id: 1 }, { id: 3 }]);
// [1, 3]

prepend

promiseAllEntries

promiseAllObject

range

  • ([start=0], end, [step=1]) => [Number a, ...]
  • source
range(4);
// => [0, 1, 2, 3]

range(-4);
// => [0, -1, -2, -3]

range(1, 5);
// => [1, 2, 3, 4]

range(0, 20, 5);
// => [0, 5, 10, 15]

range(0, -4, -1);
// => [0, -1, -2, -3]

reduce

  • ((a, b) => c) => Iterable a => c
  • ((a, b) => Promise c) => Iterable a => Promise c
  • ((a, b) => c) => Iterable Promise a => Promise c
  • ((acc, b) => acc) => acc => Iterable b => acc
  • ((acc, b) => Promise acc) => acc => Iterable b => Promise acc
  • ((acc, b) => acc) => acc => Iterable Promise b => Promise acc
  • source
const add = (a, b) => a + b;

reduce(add, [1, 2, 3]);
// 6

reduce(add, 10, [1, 2, 3]);
// 16

await reduce(add, [Promise.resolve(1), Promise.resolve(2), Promise.resolve(3)]);
// 6

reject

  • (a => Boolean) => Iterable a => []
  • (a => Boolean) => Iterable Promise a => Promise []
  • (a => Promise Boolean) => Iterable a => Promise []
  • (a => Promise Boolean) => Iterable Promise a => Promise []
  • source
reject((a) => a % 2, [1, 2, 3]);
// [2]

reject((a) => a % 2, [
  Promise.resolve(1),
  Promise.resolve(2),
  Promise.resolve(3),
]).then(log);
// [2]

reject((a) => Promise.resolve(a % 2), [1, 2, 3]).then(log);
// [2]

reject((a) => Promise.resolve(a % 2), [
  Promise.resolve(1),
  Promise.resolve(2),
  Promise.resolve(3),
]).then(log);
// [2]

remove

  • (Number start, Iterable) => Array
  • (Number start, Number count, Iterable) => Array
  • source
// remove with index
remove(0, [1, 2, 3, 4, 5]) // [1, 2, 3, 4]
remove(0, L.range(5)) // [1, 2, 3, 4]

// remove with count
remove(1, 2, [1, 2, 3, 4, 5]) // [0, 3, 4]
remove(1, 2, L.range(5)) // [0, 3, 4]

repeat

  • (a, Number size) => [a, a, a, ...a]
  • source
repeat("hi", 5) // ["hi", "hi", "hi", "hi", "hi"]

replace

  • (String substr|Regex, String newSubstr, String target) => String
  • source
// search by string
replace("foo", "bar", "foo foo foo") // "bar foo foo"

// search by regex
replace(/foo/g, "bar", "foo foo foo") // "bar bar bar"

reverse

sel

sort

sortBy

sortByDesc

sortDesc

split

splitEvery

subtract

  • (Number, Number) => Number
  • source
subtract(4, 1) // 3

sum

sumBy

tail (rest)

take

take1

takeAll

takeUntil

takeWhile

times

  • range . map
  • (f, Number n) => [f(1), f(2), ...f(n-1)]
  • source
// times(String, 3)
times(String, 3) // ["0", "1", "2"]
times(n => n * 2, 5) // [0, 2, 4, 6, 8]

// times(Promise.resolve.bind(Promise), 3)
await times(n => Promise.resolve(n), 3) // [0, 1, 2]

toIter

union

unionBy

unionWith

unique

  • Iterable a => [a]
  • Iterable a => Promise [a]
  • source
unique([1, 2, 3, 1, 2, 4]);
// [1, 2, 3, 4]

uniqueBy

  • (a => b) => Iterable a => [a]
  • (a => b) => Iterable Promise a => Promise [a]
  • (a => Promise b) => Iterable a => Promise [a]
  • (a => Promise b) => Iterable Promise a => Promise [a]
  • source
const users = [
  { name: "aa" },
  { name: "Aa" },
  { name: "bb" },
  { name: "cc" },
  { name: "bb" },
];

uniqueBy((u) => u.name.toUpperCase(), users);
// [{name: 'aa'}, {name: 'bb'}, {name: 'cc'}]

uniqueWith

unzip

update

updateBy

values

zip

zipObj

zipWith

Predicates

all

and

any

both

cond

either

equals

equals2

equalsBy

equalsBy2

every

gt

gte

has

ifElse

isArray

isFunction

isIterable

isMatch

isNil

isNil(undefined) // true
isNil(null) // true
isNil(false) // false
isNil([]) // false
isNil('') // false

isNull

isObject

isString

isUndefined

lt

lte

match

merge

not

or

satisfiesEvery

satisfiesSome

selEquals

selSatisfies

some

unless

when

Lazy

L.append

L.chunk

L.compact

L.concat

L.constant

L.deepFlat

L.difference

L.differenceBy

L.differenceWith

L.drop

L.dropUntil

L.dropWhile

L.each

L.empty

L.entries

L.filter

const iterator = L.filter((a) => a % 2, [1, 2, 3]);
iterator.next(); // { value: 1, done: false }
iterator.next(); // { value: 3, done: false }
iterator.next(); // { value: undefined, done: true }

go(
  L.range(1, Infinity),
  L.filter((a) => a % 2),
  take(2)
);
// [1, 3]

await go(
  L.range(Infinity),
  L.map((a) => Promise.resolve(a)),
  L.filter((a) => a % 2),
  take(2)
);
// [1, 3]

L.flat

L.flatMap

L.insert

L.intersection

L.intersectionBy

L.intersectionWith

L.interval

L.keys

L.limitLoad

L.map

L.mapEntries

L.prepend

L.range

L.reject

L.remove

L.repeat

L.reverse

L.slice

L.splitEvery

L.take

L.takeUntil

L.takeWhile

L.times

L.union

L.unionBy

L.unionWith

L.unique

L.uniqueBy

L.uniqueWith

L.values

L.update

L.updateBy

L.zipWithIndex

L.zip

Concurrency

C.calls

C.compact

C.drop

C.every

C.filter

C.find

C.head

C.map

C.mapEntries

C.object

C.race

C.reduce

C.some

C.tail

C.take

C.take1

C.takeAll

C.takeRace

Stoppable

reduceS stop

reduceS(
  (a, b) => {
    const res = a + b;
    return res > 5 ? stop(res) : res;
  },
  [1, 2, 3, 4]
);
// 6

goS, pipeS, stop, stopIf

const f1 = pipeS(
  (a) => (a % 2 ? stop(a) : a),
  (a) => a + 10
);
f1(1);
// 1
f1(2);
// 12

const f2 = pipeS(
  stopIf((a) => a % 2),
  (a) => a + 10
);
f2(1);
// 1
f2(2);
// 12

goS({ a: 1, b: 2 }, stopIf({ a: 1 }), ({ a, b }) => ({ a: a + 10, b }));
// {a: 1, b: 2}

goS({ a: 2, b: 2 }, stopIf({ a: 1 }), ({ a, b }) => ({ a: a + 10, b }));
// {a: 12, b: 2}

goS({ a: 1, b: 2 }, stopIf({ a: 1 }, null), ({ a, b }) => ({ a: a + 10, b }));
// null

String

html

join

strMap

string