Comments (10)
@dacz I agree it would be nice, will investigate for an FP variant
from ixjs.
can we also support _.flow
or provide a flow/compose function:
// Current
const results = of(1, 2, 3)
.chain(source => filter(source, x => x % 2 === 0))
.chain(source => map(source, x => x * x));
import * as ix from 'ix/fp/es';
import flow from 'lodash.flow';
// Possible with args switched (and curried)
const results = ix.flow(
v => ix.of(...v),
ix.filter(x => x % 2 === 0),
ix.map(x => x * x),
)([1, 2, 3]);
assert(ix.flow === flow);
from ixjs.
@dacz @graingert is the pipe
mechanism we have good enough or do we need more?
from ixjs.
@mattpodwysocki I'd like to be able to use a flow function to create other functions:
import * as ix from 'ix/fp/es';
const process = ix.flow(
v => ix.of(...v),
ix.filter(x => x % 2 === 0),
ix.map(x => x * x),
);
process([1, 2, 3]); // a new iterable.
(eg I'd like to be able to use the whole of IxJS without ever calling a method, or worrying about this
)
from ixjs.
and if/when |>
is released I'd like to be able to use that.
import * as ix from 'ix/fp/es';
const process = v => ix.of(...v)
|> ix.filter(x => x % 2 === 0)
|> ix.map(x => x * x)
);
process([1, 2, 3]); // a new iterable.
from ixjs.
@graingert that's already supported since source
would be the first applied argument as described in the proposal
import { AsyncIterableX as AsyncIterable } from 'ix';
import { map, filter } from 'ix/asynciterable';
const process = v => AsyncIterable.of(...v)
|> _ => filter(_, x => x % 2 === 0)
|> _ => map(_, x => x * x)
);
process([1, 2, 3]);
Or you can use the pipe
operators.
import { AsyncIterableX as AsyncIterable } from 'ix';
import { map, filter } from 'ix/asynciterable/pipe';
const process = v => AsyncIterable.of(...v)
|> filter(x => x % 2 === 0)
|> map(x => x * x)
);
process([1, 2, 3]);
from ixjs.
@mattpodwysocki ah good stuff. how about a single namespace to import from?
from ixjs.
@graingert that's why we have an index.ts
in each area root for just that purpose, as well as the piped.
from ixjs.
@mattpodwysocki I mean the whole library in fp/pipe form. Currently you're doing it like:
import { AsyncIterableX as AsyncIterable } from 'ix';
import { map, filter } from 'ix/asynciterable/pipe';
I want:
import { * as ix } from 'ix/fp';
from ixjs.
@graingert the present structure is in place to support all three styles. At a minimum operators for the iterable/asyncIterable will stay separate, since they share names. Importing everything from the root is convenient, but won't tree shake.
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.