-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Deyan Totev
committed
Jul 19, 2023
1 parent
87a1455
commit 9964790
Showing
5 changed files
with
36 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {binary} from 'rambda' | ||
|
||
describe('R.binary', () => { | ||
it('happy', () => { | ||
const result = binary(function(x: number, y: number, z) { | ||
expect(arguments.length).toBe(2) | ||
expect(z).toBeUndefined() | ||
expect(x).toBe(10) | ||
expect(y).toBe(20) | ||
return x + y | ||
})(10, 20, 30) | ||
result // $ExpectType number | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
export function binary(foo, bar) { | ||
if (arguments.length === 1){ | ||
return (_bar) => binary(foo, _bar); | ||
} | ||
export function binary(fn){ | ||
if (fn.length <= 2) return fn | ||
|
||
return | ||
} | ||
return (a, b) => fn(a, b) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,17 @@ | ||
import { binary } from './binary' | ||
import { binary as binaryRamda } from 'ramda' | ||
import { binary } from './binary.js' | ||
|
||
test('happy', () => { | ||
const result = binary() | ||
console.log(result) | ||
}) | ||
|
||
/* | ||
var R = require('../source/index.js'); | ||
var eq = require('./shared/eq.js'); | ||
describe('binary', function() { | ||
it('turns multiple-argument function into binary one', function() { | ||
R.binary(function(x, y, z) { | ||
eq(arguments.length, 2); | ||
eq(typeof z, 'undefined'); | ||
})(10, 20, 30); | ||
}); | ||
const result = binary(function ( | ||
x, y, z | ||
){ | ||
expect(arguments).toHaveLength(2) | ||
expect(z).toBeUndefined() | ||
expect(x).toBe(10) | ||
expect(y).toBe(20) | ||
|
||
it('initial arguments are passed through normally', function() { | ||
R.binary(function(x, y, z) { | ||
eq(x, 10); | ||
eq(y, 20); | ||
void z; | ||
})(10, 20, 30); | ||
}); | ||
}); | ||
*/ | ||
return x + y | ||
})( | ||
10, 20, 30 | ||
) | ||
expect(result).toBe(30) | ||
}) |