refactor: custom vararg

This commit is contained in:
cha0s 2021-02-01 21:56:53 -06:00
parent 76a354bab6
commit 2ea4780259

View File

@ -60,9 +60,16 @@ const Invocation = ({
/>
);
}
const j = description.vararg ? Math.min(description?.args?.length - 1, i) : i;
const options = description?.args?.[j].options;
const type = description?.args?.[j].type || 'undefined';
let darg;
if ('function' === typeof description?.args) {
darg = description?.args(i);
}
else {
const j = description.vararg ? i % description?.args?.length : i;
darg = description?.args?.[j];
}
const {options} = darg;
const type = darg.type || 'undefined';
return (
<Variant
context={context}
@ -73,7 +80,7 @@ const Invocation = ({
value={arg}
vararg={
'undefined' === type
|| (description.vararg && j === description?.args?.length - 1)
|| description.vararg
}
/>
);