Skip to content

Commit

Permalink
perf: use === for placeholder test (#3388)
Browse files Browse the repository at this point in the history
  • Loading branch information
ku8ar authored Jan 3, 2024
1 parent 96d6010 commit e02ae04
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion source/__.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import _placeholder from './internal/_placeholder.js';
/**
* A special placeholder value used to specify "gaps" within curried functions,
* allowing partial application of any combination of arguments, regardless of
Expand Down Expand Up @@ -25,4 +26,4 @@
* const greet = R.replace('{name}', R.__, 'Hello, {name}!');
* greet('Alice'); //=> 'Hello, Alice!'
*/
export default {'@@functional/placeholder': true};
export default _placeholder;
6 changes: 3 additions & 3 deletions source/internal/_isPlaceholder.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _placeholder from './_placeholder.js';

export default function _isPlaceholder(a) {
return a != null &&
typeof a === 'object' &&
a['@@functional/placeholder'] === true;
return a === _placeholder;
}
1 change: 1 addition & 0 deletions source/internal/_placeholder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {'@@functional/placeholder': true};
4 changes: 2 additions & 2 deletions test/curry.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('curry', function() {
it('supports @@functional/placeholder', function() {
var f = function(a, b, c) { return [a, b, c]; };
var g = R.curry(f);
var _ = {'@@functional/placeholder': true, x: Math.random()};
var _ = R.__;

eq(g(1)(2)(3), [1, 2, 3]);
eq(g(1)(2, 3), [1, 2, 3]);
Expand Down Expand Up @@ -167,7 +167,7 @@ describe('curry properties', function() {

it('curries with placeholder', function() {
fc.assert(fc.property(fc.func(fc.anything()), fc.anything(), fc.anything(), fc.anything(), function(f, a, b, c) {
var _ = {'@@functional/placeholder': true, x: Math.random()};
var _ = R.__;
var f3 = function(a, b, c) {
return f(a, b, c);
};
Expand Down
2 changes: 1 addition & 1 deletion test/curryN.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('curryN', function() {
it('supports @@functional/placeholder', function() {
var f = function() { return Array.prototype.slice.call(arguments); };
var g = R.curryN(3, f);
var _ = {'@@functional/placeholder': true, x: Math.random()};
var _ = R.__;

eq(g(1)(2)(3), [1, 2, 3]);
eq(g(1)(2, 3), [1, 2, 3]);
Expand Down

0 comments on commit e02ae04

Please sign in to comment.