Giter VIP home page Giter VIP logo

Comments (3)

toniov avatar toniov commented on July 17, 2024 1

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.

RaederDev avatar RaederDev commented on July 17, 2024

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.

toniov avatar toniov commented on July 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.