1.0.5 • Published 4 years ago

nvcurry v1.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

nvcurry

  • inspect a non-native function-params/arguments
  • currify-a-function similiar to lodash-curry,with more arguments-infomation

install

  • npm install nvcurry

usage

> var wrap = require("nvcurry")
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]
}
>

property

  • f.$name_cache check-arguments-cache

methods

  • f.$check() check-params
  • f.$reset() clear-arguments-cache
  • f.$exec() exec-function-forcefully even-if with no-enough-arguments-collected

LICENSE

  • ISC
1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago