Socket
Socket
Sign inDemoInstall

domexception

Package Overview
Dependencies
1
Maintainers
6
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.0 to 4.0.0

2

index.js
"use strict";
const DOMException = require("./webidl2js-wrapper.js");
const sharedGlobalObject = { Error };
const sharedGlobalObject = { Array, Error, Object, Promise, String, TypeError };
DOMException.install(sharedGlobalObject, ["Window"]);
module.exports = sharedGlobalObject.DOMException;

@@ -17,20 +17,20 @@ "use strict";

};
exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'DOMException'.`);
throw new globalObject.TypeError(`${context} is not of type 'DOMException'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
const ctor = globalObject[ctorRegistrySymbol]["DOMException"];
if (ctor === undefined) {
throw new Error("Internal error: constructor DOMException is not installed on the passed global object");
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["DOMException"].prototype;
}
return Object.create(ctor.prototype);
return Object.create(proto);
}

@@ -66,4 +66,4 @@

exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);

@@ -89,2 +89,4 @@ exports._internalSetup(wrapper, globalObject);

}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class DOMException {

@@ -96,3 +98,6 @@ constructor() {

if (curArg !== undefined) {
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'DOMException': parameter 1" });
curArg = conversions["DOMString"](curArg, {
context: "Failed to construct 'DOMException': parameter 1",
globals: globalObject
});
} else {

@@ -106,3 +111,6 @@ curArg = "";

if (curArg !== undefined) {
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'DOMException': parameter 2" });
curArg = conversions["DOMString"](curArg, {
context: "Failed to construct 'DOMException': parameter 2",
globals: globalObject
});
} else {

@@ -120,3 +128,5 @@ curArg = "Error";

if (!exports.is(esValue)) {
throw new TypeError("'get name' called on an object that is not a valid instance of DOMException.");
throw new globalObject.TypeError(
"'get name' called on an object that is not a valid instance of DOMException."
);
}

@@ -131,3 +141,5 @@

if (!exports.is(esValue)) {
throw new TypeError("'get message' called on an object that is not a valid instance of DOMException.");
throw new globalObject.TypeError(
"'get message' called on an object that is not a valid instance of DOMException."
);
}

@@ -142,3 +154,5 @@

if (!exports.is(esValue)) {
throw new TypeError("'get code' called on an object that is not a valid instance of DOMException.");
throw new globalObject.TypeError(
"'get code' called on an object that is not a valid instance of DOMException."
);
}

@@ -207,6 +221,3 @@

});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = DOMException;
ctorRegistry[interfaceName] = DOMException;

@@ -213,0 +224,0 @@ Object.defineProperty(globalObject, interfaceName, {

@@ -6,12 +6,8 @@ "use strict";

exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (typeof value !== "function") {
throw new TypeError(context + " is not a function");
throw new globalObject.TypeError(context + " is not a function");
}
function invokeTheCallbackFunction(...args) {
if (new.target !== undefined) {
throw new Error("Internal error: invokeTheCallbackFunction is not a constructor");
}
const thisArg = utils.tryWrapperForImpl(this);

@@ -26,3 +22,3 @@ let callResult;

callResult = conversions["any"](callResult, { context: context });
callResult = conversions["any"](callResult, { context: context, globals: globalObject });

@@ -39,3 +35,3 @@ return callResult;

callResult = conversions["any"](callResult, { context: context });
callResult = conversions["any"](callResult, { context: context, globals: globalObject });

@@ -42,0 +38,0 @@ return callResult;

@@ -5,3 +5,3 @@ "use strict";

function isObject(value) {
return typeof value === "object" && value !== null || typeof value === "function";
return (typeof value === "object" && value !== null) || typeof value === "function";
}

@@ -11,7 +11,57 @@

// Like `Object.assign`, but using `[[GetOwnProperty]]` and `[[DefineOwnProperty]]`
// instead of `[[Get]]` and `[[Set]]` and only allowing objects
function define(target, source) {
for (const key of Reflect.ownKeys(source)) {
const descriptor = Reflect.getOwnPropertyDescriptor(source, key);
if (descriptor && !Reflect.defineProperty(target, key, descriptor)) {
throw new TypeError(`Cannot redefine property: ${String(key)}`);
}
}
}
function newObjectInRealm(globalObject, object) {
const ctorRegistry = initCtorRegistry(globalObject);
return Object.defineProperties(
Object.create(ctorRegistry["%Object.prototype%"]),
Object.getOwnPropertyDescriptors(object)
);
}
const wrapperSymbol = Symbol("wrapper");
const implSymbol = Symbol("impl");
const sameObjectCaches = Symbol("SameObject caches");
const ctorRegistrySymbol = Symbol.for("[webidl2js] constructor registry");
const ctorRegistrySymbol = Symbol.for("[webidl2js] constructor registry");
const AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(async function* () {}).prototype);
function initCtorRegistry(globalObject) {
if (hasOwn(globalObject, ctorRegistrySymbol)) {
return globalObject[ctorRegistrySymbol];
}
const ctorRegistry = Object.create(null);
// In addition to registering all the WebIDL2JS-generated types in the constructor registry,
// we also register a few intrinsics that we make use of in generated code, since they are not
// easy to grab from the globalObject variable.
ctorRegistry["%Object.prototype%"] = globalObject.Object.prototype;
ctorRegistry["%IteratorPrototype%"] = Object.getPrototypeOf(
Object.getPrototypeOf(new globalObject.Array()[Symbol.iterator]())
);
try {
ctorRegistry["%AsyncIteratorPrototype%"] = Object.getPrototypeOf(
Object.getPrototypeOf(
globalObject.eval("(async function* () {})").prototype
)
);
} catch {
ctorRegistry["%AsyncIteratorPrototype%"] = AsyncIteratorPrototype;
}
globalObject[ctorRegistrySymbol] = ctorRegistry;
return ctorRegistry;
}
function getSameObject(wrapper, prop, creator) {

@@ -49,4 +99,2 @@ if (!wrapper[sameObjectCaches]) {

const iterInternalSymbol = Symbol("internal");
const IteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()));
const AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(async function* () {}).prototype);

@@ -58,3 +106,3 @@ function isArrayIndexPropName(P) {

const i = P >>> 0;
if (i === Math.pow(2, 32) - 1) {
if (i === 2 ** 32 - 1) {
return false;

@@ -116,2 +164,4 @@ }

hasOwn,
define,
newObjectInRealm,
wrapperSymbol,

@@ -121,2 +171,3 @@ implSymbol,

ctorRegistrySymbol,
initCtorRegistry,
wrapperForImpl,

@@ -127,4 +178,2 @@ implForWrapper,

iterInternalSymbol,
IteratorPrototype,
AsyncIteratorPrototype,
isArrayBuffer,

@@ -131,0 +180,0 @@ isArrayIndexPropName,

@@ -6,12 +6,8 @@ "use strict";

exports.convert = (value, { context = "The provided value" } = {}) => {
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
if (typeof value !== "function") {
throw new TypeError(context + " is not a function");
throw new globalObject.TypeError(context + " is not a function");
}
function invokeTheCallbackFunction() {
if (new.target !== undefined) {
throw new Error("Internal error: invokeTheCallbackFunction is not a constructor");
}
const thisArg = utils.tryWrapperForImpl(this);

@@ -18,0 +14,0 @@ let callResult;

@@ -12,3 +12,3 @@ {

],
"version": "3.0.0",
"version": "4.0.0",
"author": "Domenic Denicola <d@domenic.me> (https://domenic.me/)",

@@ -38,3 +38,3 @@ "license": "MIT",

"mocha": "^9.1.2",
"webidl2js": "^16.2.0"
"webidl2js": "^17.0.0"
},

@@ -41,0 +41,0 @@ "engines": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc