Skip to content

Instantly share code, notes, and snippets.

@Shuumatsu
Last active March 27, 2017 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shuumatsu/03d9bc903f1e1daa08e43eac4400467c to your computer and use it in GitHub Desktop.
Save Shuumatsu/03d9bc903f1e1daa08e43eac4400467c to your computer and use it in GitHub Desktop.
it('composes functions from right to left', () => {
const a = next => x => next(x + 'a')
const b = next => x => next(x + 'b')
const c = next => x => next(x + 'c')
const final = x => x
expect(compose(a, b, c)(final)('')).toBe('abc')
expect(compose(b, c, a)(final)('')).toBe('bca')
expect(compose(c, a, b)(final)('')).toBe('cab')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment