Comments (10)
If you like this idea, I'm happy to open a PR. π
from remeda.
@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.
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.
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.
@eranhirsch Sounds great! I'll try to get those over to you in the next few days.
from remeda.
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.
@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.
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.
Oh, I just wanted to make sure you were good with the approach before I did the rest of them.
from remeda.
π This issue has been resolved in version 1.34.0 π
The release is available on:
Your semantic-release bot π¦π
from remeda.
Related Issues (20)
- Updating to 1.45.0 broke types when using pipe HOT 4
- Allow `undefined`, `null` as parameters to mergeDeep HOT 3
- `setPath` only works for existing properties HOT 3
- Add linting to JSDoc HOT 2
- `isPlainObject` (and others?) impacted by breaking changes in typescript 5.4 HOT 7
- Add type safety for `purry` HOT 7
- Add type safe `curry` function HOT 5
- Typescript error "Excessive stack depth" for `hasAtLeast` HOT 5
- FR: `get` accepting deep paths into objects. HOT 7
- `mapKeys`, `mapValues`, `entries`, etc. drop symbol keys without excluding them in the return type HOT 4
- isIncludedIn narrows the negated cases too aggressively HOT 2
- Allow `conditional.defaultCase` to infer its return type HOT 3
- Incorrect type assertion for isIncludedIn HOT 5
- Add optional `obj` parameter to `Evolver`? HOT 4
- Add `invariant` HOT 2
- Add `some` and `every`? HOT 16
- [Feature Request]: Support Maps in isDeepEqual HOT 6
- Add `sortedUniq` HOT 6
- Further improve `stringToPath` types; consolidate `setPath` and `pathOr`? HOT 5
- isDeepEqual and negation in guard can break type HOT 6
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 remeda.