Comments (3)
We're looking at (very soon) switching to manual currying of these internal functions for performance reasons. So, while that's an interesting idea, it may not be necessary.
On the other note, we are not trying to match the APIs of other libraries necessarily, or of the native prototypes, especially if what they have seems wrong or harmful. It's about the classic sorts of examples:
_.map(["1.1", "2.2", "3.3"], parseFloat); //=> [1.1, 2.2, 3.3]
_.map(["1", "2", "3"], parseInt); //=> [1, NaN, NaN]
Because Underscore.map
(like the native Array.prototype.map
) passes the index as the second parameter, but parseInt expects a radix.
R.map(parseFloat, ["1.1", "2.2", "3.3"]); //=> [1.1, 2.2, 3.3]
R.map(parseInt, ["1", "2", "3"]); //=> [1, 2, 3]
Yes, we could clear this up with nAry
or the newly added unary
:
R.map.idx(R.unary(parseInt), ["1", "2", "3"]); //=> [1, 2, 3]
This feels the wrong direction to me for an FP library.
from ramda.
For max performance you will want to limit composition (currying requires wrapping thus a form of composition) while for terser code composition is great. Currying isn't needed to do most of the composition internally but will kill performance regardless of how well its tuned.
Currying the exposed API seperately is the best IMO
from ramda.
You can see what we did to where
to reduce some of the overhead. The plan is to do this across the codebase. It will be uglier, but will gain performance for all users of the functions, not just internal users. So for instance:
var prop = function(name, obj) {
return arguments.length === 0 ?
prop :
arguments.length < 2 ?
function(obj) { return obj[name]; } :
obj[name];
};
You can see this in action at http://jsperf.com/ramda-auto-curry-cost/3
from ramda.
Related Issues (20)
- r.all(r.F, {}) => true, the all function, why not add type check or return false when param not a list
- r.all(r.F, {}) => true, the all function, why not add type check or return false when param not a list HOT 2
- mergeAll bug? HOT 2
- Dead link on hompage under "Install specific functions"
- `equals` returns false if the ordering is different HOT 1
- `reduce` with partial application caches results? HOT 1
- Ramda `0.28.0` contains CWE-843 and CWE-915 HOT 1
- assocPath number path with undefined value expect array but got object HOT 1
- clone new Array(number); HOT 4
- v0.29.0 released HOT 19
- Documentation errors in R.swap examples HOT 2
- 0.29.0 Upgrade Guide HOT 14
- Example with R.find() does not work HOT 3
- `is` implementation can not pass leetcode testing HOT 7
- pathEq types are not consistent with the code in 0.29.0 HOT 5
- Cannot update a nested map via R.modifyPath HOT 2
- R.find and R.propEq HOT 2
- Version exported subfolders HOT 2
- Compose type definitions
- propEq documentation error HOT 4
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 ramda.