-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #679
- Loading branch information
Showing
4 changed files
with
57 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { nAry } from 'ramda'; | ||
|
||
/** | ||
* Accepts a function with any arity and returns a function with arity of zero. | ||
* The returned function ignores any arguments supplied to it. | ||
* | ||
* @func dropArgs | ||
* @memberOf RA | ||
* @since {@link https://char0n.github.io/ramda-adjunct/2.10.0|v2.10.0} | ||
* @category Logic | ||
* @sig (...a -> b)-> () -> b | ||
* @param {Function} fn The function with any arity | ||
* @return {Function} Returns function with arity of zero | ||
* @see {@link http://ramdajs.com/docs/#nAry|R.nAry} | ||
* @example | ||
* | ||
* const fn = (a = 1, b = 2) => a + b; | ||
* | ||
* RA.dropArgs(fn)(3, 4); //=> 3 | ||
*/ | ||
const dropArgs = nAry(0); | ||
|
||
export default dropArgs; |
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,27 @@ | ||
import * as R from 'ramda'; | ||
|
||
import * as RA from '../src'; | ||
import eq from './shared/eq'; | ||
|
||
describe('dropArgs', function() { | ||
let fn; | ||
let zeroArityFn; | ||
|
||
beforeEach(function() { | ||
fn = (a = 1, b = 2) => a + b; | ||
zeroArityFn = RA.dropArgs(fn); | ||
}); | ||
|
||
it('should drop all arguments', function() { | ||
const actual = zeroArityFn('ignore1', 'ignore2'); | ||
const expected = 3; | ||
|
||
eq(actual, expected); | ||
}); | ||
|
||
it('should support placeholder to specify "gaps"', function() { | ||
const dropArgs = RA.dropArgs(R.__); | ||
|
||
eq(dropArgs(fn)('ignore1', 'ignore2'), 3); | ||
}); | ||
}); |