Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pipe): add piped operators #75

Merged
merged 112 commits into from
Oct 29, 2017
Merged

feat(pipe): add piped operators #75

merged 112 commits into from
Oct 29, 2017

Conversation

mattpodwysocki
Copy link
Contributor

@mattpodwysocki mattpodwysocki commented Oct 10, 2017

Description:

Adds the pipe operator which allows us to compose functionality together for both Iterable and AsyncIterable.

An example of how it works is here:

import { AsyncIterableX as AsyncIterable } from 'ix/asynciterable';
import { filter } from 'ix/asynciterable/pipe/filter';
import { map } from 'ix/asynciterbale/pipe/map';

const source = AsyncIterable.of(1, 2, 3, 4, 5);
const piped = source.pipe(
  filter(async x => x % 2 === 0),
  map(async x => x * x)
);

for await (const item of piped) {
  console.log(`Item: ${item}`);
}

Related issue (if exists):

#46
#23

@jayphelps
Copy link
Member

I think you'll want pipe to be an intrinsic method rather than an operator import you need to import explicitly. i.e. no need to do import 'ix/add/asynciterable-operators/pipe';. Otherwise you lose the benefit of libraries being able to use operators without adding them to the prototype, so they won't leak them to consumers of that library. rxjs provides it as an intrinsic

This might be confusing, so said another way: pipe should probably be included by default because otherwise libraries will have to add it to the prototype, which means then your app that consumes that library might accidentally depend on the fact that the library added it. Later, when the library decides they no longer need it, and stop adding it, your app breaks. 🎉

mattpodwysocki and others added 8 commits October 26, 2017 10:20
* build(gulpfile): allow building UMD intermediate step standalone for debugging

* fix(ix): declare prototype pipe method type so it isn't minified away

* fix(pipe): export pipe operators separately so they're not minified away

* test(operators): add helper to test all three operator variants

* fix(reduce): fix scan/reduce proto method argument checks

* test(spec): execute iterable operator tests on all operator variants

* test(spec): execute asynciterable operator tests on all operator variants

* fix(ix): export OrderedIterableBase so thenBy method names are protected from Uglify

* chore(lint): fix lint
@mattpodwysocki mattpodwysocki merged commit 76a4b4f into master Oct 29, 2017
@mattpodwysocki mattpodwysocki deleted the pipe branch October 29, 2017 21:15
@trxcllnt trxcllnt changed the title feat(pipe): add piped operators [WIP - DO NOT MERGE] feat(pipe): add piped operators Oct 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants