flat-map.js 482 B

1234567891011121314151617181920212223
  1. import assert from 'assert';
  2. describe('flatMap', () => {
  3. it('maps and flattens the results using the supplied callback', async () => {
  4. let list = [];
  5. await Observable.of('a', 'b', 'c').flatMap(x =>
  6. Observable.of(1, 2, 3).map(y => [x, y])
  7. ).forEach(x => list.push(x));
  8. assert.deepEqual(list, [
  9. ['a', 1],
  10. ['a', 2],
  11. ['a', 3],
  12. ['b', 1],
  13. ['b', 2],
  14. ['b', 3],
  15. ['c', 1],
  16. ['c', 2],
  17. ['c', 3],
  18. ]);
  19. });
  20. });