0%

npm库-fn-args

fn-args: 获取函数的所有参数名

6.0 开始,只能以 ESM 的形式引入

5.0 的版本支持 CJS

fn-args-exp.js

1
2
3
const jiti = require('jiti')();

jiti('./');

index.ts

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import fnArgs from 'fn-args';



const f1 = function (name, age) {};

function f2(a, b, c) {}

const f3 = (d, e, f) => {};

const f4 = async (g, h) => {};

const f5 = function* (i, j) {};



console.log(fnArgs(f1));

console.log(fnArgs(f2));

console.log(fnArgs(f3));

console.log(fnArgs(f4));

console.log(fnArgs(f5));
image(2)