Comments (3)
Thanks for the issue!
Yeah being able to use other JS iterable objects should be nice.
At the beginning I just wanted to keep it simple, as a replacement for ES5 Array methods.
Other reason I kept it this way is that some of p-iteration
methods maybe doesn't make sense for other iterable objects apart from Array.
What do you think about it? Does it make sense to you, for example, using map()
with a Set
?
Releasing a version 2.0.0 changing the API is also an option I've been thinking about.
from p-iteration.
I think most methods would make sense for most supported data-types.
You could have a Set of userIds and want to map them to a Set of Users for example.
await map(new Set([1, 2]), async uid => await fetchUser(uid));
I'm sure there are some cases where it doesn't make sense at all, but people often have strange use-cases. Especially map and forEach make sense for almost everything.
The reason I opened the issue is because I wanted to use the library to iterate over a Map like this:
const orders = new Map();
orders.set('o1', {superSecretData: 42});
orders.set('o2', {superSecretData: 42});
await forEach(orders, async ([,val]) => await sendToServer(val));
If you think about releasing a version 2.0, maybe it would also be a nice idea to switch the order of function and data to data last like lodash/fp does it. That way it would be very easy to partially apply a function for later use.
const logToServer = forEach.bind(null, async data => {
await Promise.resolve('Server API dummy function ' + data);
});
logToServer([1, 2]);
logToServer([3, 4]);
from p-iteration.
Thanks for your opinion and sorry for the super late reply.
I think that definitely I'll make it compatible with the rest of types.
If you think about releasing a version 2.0, maybe it would also be a nice idea to switch the order of function and data to data last like lodash/fp does it. That way it would be very easy to partially apply a function for later use.
This looks good but I would add it as an option (similar to lodash/fp), because I think that that order would be unfamiliar to most of the people.
from p-iteration.
Related Issues (11)
- Add mapParallel and forEachParallel HOT 1
- Does not compile in error es2016 preset? HOT 9
- Package is distributed under license MIT or ISC? HOT 1
- Is it possible to use in a chain? HOT 1
- Possible to limit the number of concurrent iterations? HOT 1
- Take over maintenance HOT 1
- Collaborate on asyncp HOT 2
- Unexpected token HOT 2
- Safari Support HOT 3
- "Failed to minify the code" HOT 2
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 p-iteration.