ramda icon indicating copy to clipboard operation
ramda copied to clipboard

Retain function name after curry

Open nfantone opened this issue 6 years ago • 3 comments

I saw #1678, but it's an old one and didn't get any traction. How would you feel about implementing this, at least, for curry and curryN? The idea is that functions returned by curry/curryN would keep the name of the original function passed as argument. Intermediate functions (returned before supplying all arguments) should also be aptly named.

> const { curry } = require('ramda');
undefined
> const sum = curry(function sum(a, b) { return a + b; });
undefined
> sum.name // currently -> ''
'sum'
> sum(42).name // currently -> ''
'sum'

I have a very simple, but working implementation of this, leveraging Object.defineProperty. Would you be up for a PR?

nfantone avatar Feb 04 '19 13:02 nfantone

Feel free to create a PR. I'm looking at large changes for after 1.0 that would definitely include something like this.

CrossEye avatar Feb 05 '19 00:02 CrossEye

@CrossEye Here: https://github.com/ramda/ramda/pull/2782. Let me know your feedback.

nfantone avatar Feb 05 '19 16:02 nfantone

wouldn't this be a little counter intuitive when debugging? if I curry the function sum and call it curriedSum I expect to see curriedSum in my call stack. seeing it in node CLI also looks confusing.

{ sum: [Function: sum], curriedSum: [Function: sum] }

edit: nevermind, I just noticed the date

webduvet avatar Sep 22 '21 12:09 webduvet