Sha256: 004330c930102124a0e68bf1925f971e2408797e9044949f41c2cf2ff400e1a7
Contents?: true
Size: 1.21 KB
Versions: 55
Compression:
Stored size: 1.21 KB
Contents
import accumulate from './accumulate' describe('accumulate()', () => { it('accumulation empty', () => { const accumulator = (e: number) => e * e expect(accumulate([], accumulator)).toEqual([]) }) xit('accumulate squares', () => { const accumulator = (n: number) => n * n const result = accumulate([1, 2, 3], accumulator) expect(result).toEqual([1, 4, 9]) }) xit('accumulate upcases', () => { const accumulator = (word: string) => word.toUpperCase() const result = accumulate('hello world'.splxit(/\s/), accumulator) expect(result).toEqual(['HELLO', 'WORLD']) }) xit('accumulate reversed strings', () => { const accumulator = (word: string) => word.splxit('').reverse().join('') const result = accumulate('the quick brown fox etc'.splxit(/\s/), accumulator) expect(result).toEqual(['eht', 'kciuq', 'nworb', 'xof', 'cte']) }) xit('accumulate recursively', () => { const result = accumulate('a b c'.splxit(/\s/), (char: string) => accumulate('1 2 3'.splxit(/\s/), (digit: number) => char + digit)) expect(result).toEqual([['a1', 'a2', 'a3'], ['b1', 'b2', 'b3'], ['c1', 'c2', 'c3']]) }) })
Version data entries
55 entries across 55 versions & 1 rubygems