noargs-wrapper 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/index.js +7 -3
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ $ npm install noargs-wrapper
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
This function takes in a function, and returns a wrapper that calls the passed-in function with no arguments, even if arguments are passed in to the wrapper.
|
|
13
|
+
This function takes in a function, and returns a wrapper that calls the passed-in function with no arguments, even if arguments are passed in to the wrapper. (unless the function passed in takes over 100 arguments)
|
|
14
14
|
|
|
15
15
|
Here's an example:
|
|
16
16
|
|
package/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
var nAry = require('ramda.nary')
|
|
2
|
+
var zero = require('number-zero')
|
|
3
|
+
var isFunction = require('@is-(unknown)/is-function')
|
|
4
|
+
var throwup = require('get-intrinsic')('%ThrowTypeError%')
|
|
5
|
+
var not = require("es-logical-not-operator")
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
8
|
* Wrap a function so it's always called with no arguments.
|
|
@@ -6,10 +10,10 @@ var nAry = require('ramda.nary')
|
|
|
6
10
|
* @returns {Function} - A new function that ignores all passed arguments
|
|
7
11
|
*/
|
|
8
12
|
function noArgsWrapper(fn) {
|
|
9
|
-
if (
|
|
10
|
-
|
|
13
|
+
if (not(isFunction(fn))) {
|
|
14
|
+
throwup()
|
|
11
15
|
}
|
|
12
|
-
return nAry(
|
|
16
|
+
return nAry(zero, fn)
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
module.exports = noArgsWrapper
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "noargs-wrapper",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Wrap a function to always call it with no arguments, ignoring all arguments passed in.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"function",
|
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
"type": "commonjs",
|
|
24
24
|
"main": "index.js",
|
|
25
25
|
"dependencies": {
|
|
26
|
+
"@is-(unknown)/is-function": "^1.0.3",
|
|
27
|
+
"es-logical-not-operator": "^1.0.0",
|
|
28
|
+
"get-intrinsic": "^1.3.0",
|
|
29
|
+
"number-zero": "^1.0.3",
|
|
26
30
|
"ramda.nary": "^0.26.1"
|
|
27
31
|
}
|
|
28
32
|
}
|