Comparing version 1.0.1 to 1.0.2
26
index.js
@@ -6,3 +6,4 @@ 'use strict'; | ||
// robust against the environment being modified after it is required. | ||
const { prototype } = Function; | ||
const FunctionBuiltin = {}.constructor.constructor; | ||
const { prototype } = FunctionBuiltin; | ||
const { toString } = prototype; | ||
@@ -114,4 +115,3 @@ const { apply } = Reflect; | ||
arityOf.getPolyfill = function getPolyfill() { | ||
// TODO: look for native | ||
return arityOf; | ||
return FunctionBuiltin.arityOf || arityOf; | ||
}; | ||
@@ -126,4 +126,15 @@ | ||
arityOf.shim = function shim() { | ||
if (!hasOwnProperty(prototype, 'maxArity')) { | ||
const polyfill = arityOf.getPolyfill(); | ||
if (!apply(hasOwnProperty, FunctionBuiltin, [ 'arityOf' ])) { | ||
defineProperty( | ||
FunctionBuiltin, | ||
'arityOf', | ||
{ | ||
configurable: true, | ||
writable: true, | ||
value: polyfill, | ||
}); | ||
} | ||
if (!apply(hasOwnProperty, prototype, [ 'maxArity' ])) { | ||
defineProperty( | ||
prototype, | ||
@@ -134,7 +145,7 @@ 'maxArity', | ||
get() { | ||
return arityOf(this).max; | ||
return polyfill(this).max; | ||
}, | ||
}); | ||
} | ||
if (!hasOwnProperty(prototype, 'usesRest')) { | ||
if (!apply(hasOwnProperty, prototype, [ 'usesRest' ])) { | ||
defineProperty( | ||
@@ -146,6 +157,7 @@ prototype, | ||
get() { | ||
return arityOf(this).usesRest; | ||
return polyfill(this).usesRest; | ||
}, | ||
}); | ||
} | ||
// TODO: do we need to install on AsyncFunction, GeneratorFunction, etc. | ||
}; |
{ | ||
"name": "arity-of", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Exposes max arity and other metadata for JS functions", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24815
284