diff --git a/src/core/curry.js b/src/core/curry.js index 0b2c94af4..c2b6482a5 100644 --- a/src/core/curry.js +++ b/src/core/curry.js @@ -43,6 +43,12 @@ function curry(fn) { value: true }) + Object.defineProperty(curried, 'length', { + enumerable: false, + writable: false, + value: fn.length + }) + return curried } diff --git a/src/core/curry.spec.js b/src/core/curry.spec.js index 2788312d7..e37c1f88e 100644 --- a/src/core/curry.spec.js +++ b/src/core/curry.spec.js @@ -78,3 +78,11 @@ test('curry on a curried function', t => { t.end() }) + +test('curried function with arity exposed', t => { + const fn = (a, b) => a + b + const curried = curry(fn) + t.equal(curried.length, fn.length, 'returns the same arity as its uncurried counterpart') + + t.end() +})