Comments (4)
Or better yet, why not match RxJS's import style? I would assume most users of IxJS would be RxJS folks not wanting to learn another transducer library. Is that assumption correct?
If so, wouldn't ixjs/operators
make the most sense?
Also, I noticed this example was wrong as well:
// ES
import { AsyncIterableX as AsyncIterable } from 'ix/asynciterable';
import { filter, map } from 'ix/asynciterable/pipe';
// CommonJS
const AsyncIterable = require('ix/asynciterable').AsyncIterableX;
const { filter, map } = require('ix/asynciterable/pipe');
const source = async function* () {
yield 1;
yield 2;
yield 3;
yield 4;
};
const results = from(source()).pipe(
filter(async x => x % 2 === 0),
map(async x => x * x)
);
for await (let item of results) {
console.log(`Next: ${item}`);
}
In this example, AsyncIterable
is imported, but from
is never imported directly. Should it be AsyncIterable.from
instead? Or even better, from
or fromPromise
which doesn't require pulling values off an object.
In RxJS, you can use from
for Array, Iterable, Promise (async), and Observable so I would imagine IxJS would be able to tell if it's dealing with Iterable vs AsyncIterable in the same way; although, I dunno if it would be as simple as it is with RxJS's from
.
Either way, having a separate iterator method would help with tree-shaking and ensure more similarities to RxJS.
from ixjs.
I had a quick look through and to explain what's happening with your points respectively:
- The
of
operator comes from aboveIterable
object. So this example should really beIterable.of
- The
import { map, filter } from 'ix/iterable/pipe';
doesn't do what we expect here becauseimport ... from 'ix/iterable/pipe'
returns us the functionpipe
not the subdirectory which contains the pipe-able (lettable) functionality. In order to access themap
andfilter
lettable functions we need to dig deeper and actually go into the 'pipe' subdirectory. So for ex. something likeimport { map, filter } from 'ix/iterable/pipe/'
Does that make sense? It's not ideal having these names clash. I'll make a pull request to the docs updating the above points and see if anyone has an opinion about a different way to get access to the lettable functions. Maybe a directory called lettable
instead of pipe
would be a good start?
from ixjs.
Bit more info from doing this:
require.resolve('ix/iterable/pipe');
=> .../ix/node_modules/ix/iterable/pipe.js
whereas
require.resolve('ix/iterable/pipe/');
.../ix/node_modules/ix/iterable/pipe/index.js
from ixjs.
@desnor That makes sense to me!
from ixjs.
Related Issues (20)
- Adding a helper module for bringing in everything HOT 3
- What happened to the function signature on reduce (and scan)? HOT 4
- takeUntil should complete iterator immediately
- docs(readme): `Array#extras` link is defunct HOT 2
- Spurious 'unhandledRejection' events HOT 1
- Weird memory behaviour with merge HOT 1
- async timeout operator does not pass through its input HOT 2
- pipe() should work recursively, and the free standing pipe() should work inside the pipe chain method HOT 4
- Merge with iter-tools? HOT 3
- Typescript >= 4.3.2 HOT 1
- [Suggestion]: Update `@types/node`
- vite environment ix package load error
- Usage with Skypack CDN? HOT 2
- ES modules do not work HOT 1
- Build errors with Typescript 4.7.4 HOT 4
- Take while inclusive
- Operator flat concurrency issue with async iterables HOT 7
- from with abort signal HOT 1
- merge function can cause unhandled rejected promise condition
- async iterable merge function that ends upon the first "done"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ixjs.