Coder Social home page Coder Social logo

Comments (10)

LandonSchropp avatar LandonSchropp commented on May 31, 2024

If you like this idea, I'm happy to open a PR. πŸ™‚

from remeda.

eranhirsch avatar eranhirsch commented on May 31, 2024

@TkDodo, I know these are added as examples in our mapping.Md file, but I personally feel it's OK to have them implemented as functions (similar to how 'prop' is helpful when it's similarly simple as an arrow function: ({ [prop]: value }) => value

from remeda.

LandonSchropp avatar LandonSchropp commented on May 31, 2024

For context, this fell out of some of my Advent of Code answers from this year. I found myself repeating this a lot:

return result.reduce((sum, number) => sum + number, 0);

I liked the idea of add as a utility function because I thought it made the code a bit more readable.

return result.reduce(R.add);

sumBy was an option that I used as well with R.identity:

return R.sumBy(result, R.identity);

However, it seems R.sum would be a bit tidier. (sumBy could be thought of as a composition of map and sum in this context.)

return R.sum(result);

I'm happy to close this if you'd likeβ€”just thought I'd suggest it. What do you think?

from remeda.

eranhirsch avatar eranhirsch commented on May 31, 2024

I checked our docs, and lodash's and ramda's docs, and I am supportive of adding add, subtract, divide, and multiply. I'm especially interested in having dataLast implementations of these readily available for things like R.map(anArrayOfNumbers, R.add(SOME_CONST));

Can you send out a PR for these and I'll review it? You can bunch all of them into a single PR

from remeda.

LandonSchropp avatar LandonSchropp commented on May 31, 2024

@eranhirsch Sounds great! I'll try to get those over to you in the next few days.

from remeda.

LandonSchropp avatar LandonSchropp commented on May 31, 2024

I personally feel it's OK to have them implemented as functions

Apologies, I read that wrong the first time. For some reason, I thought you wrote that you didn't feel that it was OK to have them implemented as functions. 😬

from remeda.

LandonSchropp avatar LandonSchropp commented on May 31, 2024

@eranhirsch Hey, did you see this draft PR I opened? No worries if you're busy hand haven't had a chance to lookβ€”I just wanted to make sure you didn't miss it. πŸ™‚

from remeda.

eranhirsch avatar eranhirsch commented on May 31, 2024

Your comments sounded like you were planning to continue working on it, and I usually don't go over draft PRs. Is there a reason you are keeping the PR in draft?

from remeda.

LandonSchropp avatar LandonSchropp commented on May 31, 2024

Oh, I just wanted to make sure you were good with the approach before I did the rest of them.

from remeda.

TkDodo avatar TkDodo commented on May 31, 2024

πŸŽ‰ This issue has been resolved in version 1.34.0 πŸŽ‰

The release is available on:

Your semantic-release bot πŸ“¦πŸš€

from remeda.

Related Issues (20)

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.