* Creates a bound function from the provided function using the
* provided this value and arguments list.
*
- * ☡ As with call and construct, the arguments must be passed as an
- * array.
+ * ☡ As with `call` and `construct`, the arguments must be passed as
+ * an array.
*/
bind,
* first argument as the `this` value and the remaining arguments
* passed through.
*
- * ※ This is effectively an alias for Function.prototype.call.bind.
+ * ※ This is effectively an alias for `Function::call.bind`.
*/
makeCallable,
} = (() => {
};
})();
-/**
- * Calls the provided function with the provided this value and
- * arguments list.
- *
- * ☡ This is an alias for Reflect.apply—the arguments must be passed
- * as an array.
- */
-export const call = Reflect.apply;
+export const {
+ /**
+ * Calls the provided function with the provided this value and
+ * arguments list.
+ *
+ * ☡ This is an alias for `Reflect.apply`—the arguments must be
+ * passed as an arraylike.
+ */
+ apply: call,
-/**
- * Constructs the provided function with the provided arguments list
- * and new target.
- *
- * ☡ This is an alias for Reflect.construct—the arguments must be
- * passed as an array.
- */
-export const construct = Reflect.construct;
+ /**
+ * Constructs the provided function with the provided arguments list
+ * and new target.
+ *
+ * ☡ This is an alias for `Reflect.construct`—the arguments must be
+ * passed as an arraylike.
+ */
+ construct,
+} = Reflect;
/**
* Returns the provided value.
export const isConstructor = ($) => {
// The provided value is an object.
try {
+ // Try constructing a new object with the provided value as its
+ // `new.target`. This will throw if the provided value is not a
+ // constructor.
construct(
function () {},
[],
$,
- ); // will throw if $ is not a constructor
+ );
return true;
} catch {
+ // The provided value was not a constructor.
return false;
}
};