ITADN

[Replacement]: `util-arity`

#1057Openoutslept 创建于 2 天前
accepted
O
outsleptcommented
### Package to replace `util-arity` ### Suggested replacement(s) ```js export default function arrity (arity, fn) { if (typeof arity !== 'number') { throw new TypeError('Expected arrity to be a number, got ' + arity) } const wrapper = function (...args) { return fn.apply(this, args) } return Object.defineProperty(wrapper, 'length', { value: arity }) } ``` ### Manifest type micro-utility (tiny utility replaceable with native code or removal) ### Rationale The package exists solely to set `fn.length`, which wasn't configurable in ES5. Since ES2015, `Function.prototype.length` became configurable, so we can make things a bit more beautiful ### Availability _No response_ ### Code example (optional) ```js ```
2 条评论