(b: B, f: (s: B, a: A) => B)
| 1 | /** @internal */ |
| 2 | export function reduce<A, B>(b: B, f: (s: B, a: A) => B) { |
| 3 | return function(iterable: Iterable<A>): B { |
| 4 | if (Array.isArray(iterable)) { |
| 5 | return iterable.reduce(f, b) |
| 6 | } |
| 7 | let result = b |
| 8 | for (const n of iterable) { |
| 9 | result = f(result, n) |
| 10 | } |
| 11 | return result |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | /** @internal */ |
| 16 | export function map<A, B>(f: (a: A) => B) { |
no test coverage detected