source: frontend/node_modules/whatwg-url/dist/Function.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.2 KB
Line 
1"use strict";
2
3const conversions = require("webidl-conversions");
4const utils = require("./utils.js");
5
6exports.convert = (value, { context = "The provided value" } = {}) => {
7 if (typeof value !== "function") {
8 throw new TypeError(context + " is not a function");
9 }
10
11 function invokeTheCallbackFunction(...args) {
12 if (new.target !== undefined) {
13 throw new Error("Internal error: invokeTheCallbackFunction is not a constructor");
14 }
15
16 const thisArg = utils.tryWrapperForImpl(this);
17 let callResult;
18
19 for (let i = 0; i < args.length; i++) {
20 args[i] = utils.tryWrapperForImpl(args[i]);
21 }
22
23 callResult = Reflect.apply(value, thisArg, args);
24
25 callResult = conversions["any"](callResult, { context: context });
26
27 return callResult;
28 }
29
30 invokeTheCallbackFunction.construct = (...args) => {
31 for (let i = 0; i < args.length; i++) {
32 args[i] = utils.tryWrapperForImpl(args[i]);
33 }
34
35 let callResult = Reflect.construct(value, args);
36
37 callResult = conversions["any"](callResult, { context: context });
38
39 return callResult;
40 };
41
42 invokeTheCallbackFunction[utils.wrapperSymbol] = value;
43 invokeTheCallbackFunction.objectReference = value;
44
45 return invokeTheCallbackFunction;
46};
Note: See TracBrowser for help on using the repository browser.