Socket
Socket
Sign inDemoInstall

webidl2js

Package Overview
Dependencies
4
Maintainers
6
Versions
57
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 11.0.0 to 12.0.0

12

lib/output/utils.js

@@ -66,2 +66,13 @@ "use strict";

const byteLengthGetter =
Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
function isArrayBuffer(value) {
try {
byteLengthGetter.call(value);
return true;
} catch (e) {
return false;
}
}
const supportsPropertyIndex = Symbol("supports property index");

@@ -92,2 +103,3 @@ const supportedPropertyIndices = Symbol("supported property indices");

IteratorPrototype,
isArrayBuffer,
isArrayIndexPropName,

@@ -94,0 +106,0 @@ supportsPropertyIndex,

15

lib/parameters.js

@@ -145,19 +145,6 @@ "use strict";

// Handle Error and DOMException the same way
const exceptions = S.filter(o => {
return isOrIncludes(ctx, o.typeList[d], t => Types.exceptionTypes.has(t.idlType));
});
if (exceptions.length) {
possibilities.push(`
if (curArg instanceof Error) {
${continued(exceptions[0], i)}
}
`);
}
const arrayBuffers = S.filter(o => isOrIncludes(ctx, o.typeList[d], t => t.idlType === "ArrayBuffer"));
if (arrayBuffers.length) {
possibilities.push(`
if (curArg instanceof ArrayBuffer ||
typeof SharedArrayBuffer !== "undefined" && curArg instanceof SharedArrayBuffer) {
if (utils.isArrayBuffer(curArg)) {
${continued(arrayBuffers[0], i)}

@@ -164,0 +151,0 @@ }

@@ -21,3 +21,2 @@ "use strict";

]);
const exceptionTypes = new Set(["Error", "DOMException"]);

@@ -192,10 +191,5 @@ const resolvedMap = new WeakMap();

// Handle Error and DOMException the same way
if (union.exception || union.object) {
output.push(`if (${name} instanceof Error) {}`);
}
// Do not convert buffer source types as the impl code can either "get a reference" or "get a copy" to the bytes.
if (union.ArrayBuffer || union.object) {
output.push(`if (${name} instanceof ArrayBuffer) {}`);
output.push(`if (utils.isArrayBuffer(${name})) {}`);
}

@@ -206,3 +200,3 @@ if (union.ArrayBufferViews.size > 0 || union.object) {

if (union.ArrayBufferViews.size !== arrayBufferViewTypes.size) {
const exprs = [...union.ArrayBufferViews].map(a => `${name} instanceof ${a}`);
const exprs = [...union.ArrayBufferViews].map(a => `${name}.constructor.name === "${a}"`);
condition += ` && (${exprs.join(" || ")})`;

@@ -401,3 +395,2 @@ }

object: false,
exception: null,
string: null,

@@ -411,3 +404,3 @@ numeric: null,

get interfaceLike() {
return this.interfaces.size > 0 || this.exception !== null || this.BufferSource;
return this.interfaces.size > 0 || this.BufferSource;
},

@@ -467,10 +460,2 @@ unknown: false

seen.object = true;
} else if (exceptionTypes.has(item.idlType)) {
if (seen.object) {
error("Exception types are not distinguishable with object type");
}
if (seen.exception && seen.exception.idlType !== item.idlType) {
error("DOMException is not distinguishable with Error type");
}
seen.exception = item;
} else if (item.idlType === "boolean") {

@@ -587,3 +572,2 @@ seen.boolean = item;

extracted1.object === extracted2.object &&
sameType(ctx, extracted1.exception, extracted2.exception) &&
sameType(ctx, extracted1.string, extracted2.string) &&

@@ -643,5 +627,5 @@ sameType(ctx, extracted1.numeric, extracted2.numeric) &&

const isInterfaceLike1 = ctx.interfaces.has(inner1.idlType) || exceptionTypes.has(inner1.idlType) ||
const isInterfaceLike1 = ctx.interfaces.has(inner1.idlType) ||
bufferSourceTypes.has(inner1.idlType);
const isInterfaceLike2 = ctx.interfaces.has(inner2.idlType) || exceptionTypes.has(inner2.idlType) ||
const isInterfaceLike2 = ctx.interfaces.has(inner2.idlType) ||
bufferSourceTypes.has(inner2.idlType);

@@ -667,3 +651,2 @@ const isDictionaryLike1 = ctx.dictionaries.has(inner1.idlType) || inner1.generic === "record";

(!isInterfaceLike2 ||
!(inner2.idlType === "Error" && inner1.idlType === "DOMException") &&
(!ctx.interfaces.has(inner2.idlType) ||

@@ -691,3 +674,2 @@ !new Set(ctx.interfaces.get(inner2.idlType).allInterfaces()).has(inner1.idlType)));

numericTypes,
exceptionTypes,

@@ -694,0 +676,0 @@ generateTypeConversion,

{
"name": "webidl2js",
"version": "11.0.0",
"version": "12.0.0",
"description": "Auto-generates class structures for WebIDL specifications",

@@ -10,3 +10,3 @@ "main": "lib/transformer.js",

"prettier": "^1.19.1",
"webidl-conversions": "^4.0.0",
"webidl-conversions": "^5.0.0",
"webidl2": "^23.10.1"

@@ -13,0 +13,0 @@ },

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