Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bluelovers/node-func-args
ECMAScript Function Arguments parser, Get arguments of a function, useful for and used in dependency injectors. Works for regular functions, generator functions and arrow functions.
https://github.com/bluelovers/node-func-args
Last synced: 3 days ago
JSON representation
ECMAScript Function Arguments parser, Get arguments of a function, useful for and used in dependency injectors. Works for regular functions, generator functions and arrow functions.
- Host: GitHub
- URL: https://github.com/bluelovers/node-func-args
- Owner: bluelovers
- Created: 2018-06-04T07:14:48.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-06-11T05:53:06.000Z (over 6 years ago)
- Last Synced: 2024-11-02T16:24:06.229Z (11 days ago)
- Language: TypeScript
- Size: 11.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# func-args
ECMAScript Function Arguments parser, Get arguments of a function, useful for and used in dependency injectors. Works for regular functions, generator functions and arrow functions.
```nodemon
npm install func-args
```## api
* [index.d.ts](index.d.ts)
* by default will throw error if func is native or bounded func## demo
see [_tests.ts](test/_tests.ts)
```ts
import { parseFunc } from 'func-args';let fn = async (a, b, c, {e, d, }, [aa1, aa2, { aaa3 }, [ bbb1, bbb2, { bbb4 } ], ...rrr], e2 = null, f = {
g: 7,
a: 8,
b: {
c: 555,
d: true,
},
},
f2 = (333), ...argv) => {};let { args, params } = parseFunc(fn);
console.dir({
/**
* func args with structure
*/
args,/**
* all func args name
*
* @type string[]
*/
params,}, {
depth: 6,
});
/*
{ args:
[ 'a',
'b',
'c',
{ e: 'e', d: 'd' },
[ 'aa1',
'aa2',
{ aaa3: 'aaa3' },
[ 'bbb1', 'bbb2', { bbb4: 'bbb4' } ],
'...rrr' ],
'e2',
'f',
'f2',
'...argv' ],
params:
[ 'a',
'b',
'c',
'e',
'd',
'aa1',
'aa2',
'aaa3',
'bbb1',
'bbb2',
'bbb4',
'...rrr',
'e2',
'f',
'f2',
'...argv' ] }
*/// skip throw error if func is native or bounded func
console.dir(parseFunc(Math.abs, true), {
depth: 6,
});
/*
{ type: undefined,
name: 'abs',
native: true,
generator: undefined,
async: undefined,
args: [],
params: [],
source: 'function abs() { [native code] }' }
*/
```