- inspect a non-native function-params/arguments
- currify-a-function similiar to lodash-curry,with more arguments-infomation
- npm install nv-facutil-curry
> var wrap = require("nv-facutil-curry")
undefined
> function tst0(a,b,c) { console.log(a,b,c)}
undefined
> var f = wrap(tst0)
> f.$check()
[
'a',
'b',
'c',
is_last_rest: false,
required_num: 3,
total_param_num: 3,
is_native: false
]
>
> f(100)
[Function: f] {
'$name_cache': { a: 100 },
'$reset': [Function],
'$exec': [Function],
'$check': [Function]
}
> f(200)
[Function: f] {
'$name_cache': { a: 100, b: 200 },
'$reset': [Function],
'$exec': [Function],
'$check': [Function]
}
> f(300)
100 200 300
undefined
>
> function tst1(a,b,c=5) { console.log(a,b,c)}
undefined
> var f = wrap(tst1)
undefined
> f.$check()
[
'a',
'b',
'c = 5',
is_last_rest: false,
required_num: 3,
total_param_num: 3,
is_native: false
]
> f(100,200)
[Function: f] {
'$name_cache': { a: 100, b: 200 },
'$reset': [Function],
'$exec': [Function],
'$check': [Function]
}
> f(300)
100 200 300
undefined
> f
[Function: f] {
'$name_cache': {},
'$reset': [Function],
'$exec': [Function],
'$check': [Function]
}
>
> function tst2(a,b,c=5,...d) {console.log(a,b,c,...d)}
undefined
> var f = wrap(tst2)
undefined
> f(100,200,300)
[Function: f] {
'$name_cache': { a: 100, b: 200, 'c = 5': 300 },
'$reset': [Function],
'$exec': [Function],
'$check': [Function]
}
> f(400,500)
[Function: f] {
'$name_cache': { a: 100, b: 200, 'c = 5': 300, '...d[0]': 400, '...d[1]': 500 },
'$reset': [Function],
'$exec': [Function],
'$check': [Function]
}
> f.$exec()
100 200 300 400 500
undefined
> f
[Function: f] {
'$name_cache': { a: 100, b: 200, 'c = 5': 300, '...d[0]': 400, '...d[1]': 500 },
'$reset': [Function],
'$exec': [Function],
'$check': [Function]
}
> f.$reset()
undefined
> f
[Function: f] {
'$name_cache': {},
'$reset': [Function],
'$exec': [Function],
'$check': [Function]
}
>
- f.$name_cache check-arguments-cache
- f.$check() check-params
- f.$reset() clear-arguments-cache
- f.$exec() exec-function-forcefully even-if with no-enough-arguments-collected
@#ts-node
> import * as lib from "@babel/parser"
{}
> import * as wrap from "nv-facutil-curry"
undefined
> var f = wrap(lib.parse)
undefined
> f.$check()
[
'input',
'options',
is_last_rest: false,
required_num: 2,
total_param_num: 2,
is_native: false
]
> .exit