Skip to content

Commit

Permalink
Fix memoize with more than 1 argument
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloocana authored and kedashoe committed Jun 1, 2017
1 parent 4455bc8 commit c5ddc1f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/memoize.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ var toString = require('./toString');
* factorial(5); //=> 120
* count; //=> 1
*/
module.exports = memoizeWith(toString);
module.exports = memoizeWith(function() {
return toString(arguments);
});
17 changes: 17 additions & 0 deletions test/memoize.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,21 @@ describe('memoize', function() {
eq(count, 1);
});

it('works with 2 arguments', function() {
var called = 0;

var add = R.memoize(function(x, y) {
called += 1;
return x + y;
});

eq(add(1, 2), 3);
eq(called, 1);

eq(add(1, 2), 3);
eq(called, 1);

eq(add(1, 3), 4);
eq(called, 2);
});
});

0 comments on commit c5ddc1f

Please sign in to comment.