Socket
Socket
Sign inDemoInstall

webidl2

Package Overview
Dependencies
Maintainers
1
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webidl2 - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4

11

lib/webidl2.js

@@ -154,4 +154,11 @@

consume(OTHER, "]") || error("Unterminated array type");
if (!obj.array) obj.array = 1;
else obj.array++;
if (!obj.array) {
obj.array = 1;
obj.nullableArray = [obj.nullable];
}
else {
obj.array++;
obj.nullableArray.push(obj.nullable);
}
obj.nullable = false;
}

@@ -158,0 +165,0 @@ else return;

2

package.json
{
"name": "webidl2"
, "description": "A WebIDL Parser"
, "version": "2.0.3"
, "version": "2.0.4"
, "author": "Robin Berjon <robin@berjon.com>"

@@ -6,0 +6,0 @@ , "dependencies": {

@@ -110,2 +110,35 @@

#### Interactions between `nullable` and `array`
A more complex data model for our AST would likely represent `Foo[][][]` as a series of
nested types four levels deep with three anonymous array types eventually containing a
`Foo` type. But experience shows that such structures are cumbersome to use, and so we
have a simpler model in which the depth of the array is specified with the `array` field.
This is all fine and well, and in the vast majority of cases is actually simpler. But it
does run afoul of cases in which it is necessary to distinguish between `Foo[][][]?`,
`Foo?[][][]`, `Foo[][]?[]`, or even `Foo?[]?[]?[]?`.
For this, when a type is an array type an additional `nullableArray` field is made available
that captures which of the arrays contain nullable elements. It contains booleans that are
true if the given array depth contains nullable elements, and false otherwise (mapping that to
the syntax, and item is true if there is a `?` preceding the `[]`). These examples ought to
clarify the model:
Foo[][][]?
-> nullable: true
-> nullableArray: [false, false, false]
Foo?[][][]
-> nullable: false
-> nullableArray: [true, false, false]
Foo[][]?[]
-> nullable: false
-> nullableArray: [false, false, true]
Foo?[]?[]?[]?
-> nullable: true
-> nullableArray: [true, true, true]
Of particular importance, please note that the overall type is only `nullable` if there is
a `?` at the end.
### Interface

@@ -112,0 +145,0 @@ Interfaces look like this:

@@ -17,2 +17,3 @@ [

"array": 2,
"nullableArray": [false, false],
"union": false,

@@ -19,0 +20,0 @@ "idlType": "unsigned short"

@@ -38,2 +38,3 @@ [

"array": 1,
"nullableArray": [false],
"union": false,

@@ -40,0 +41,0 @@ "idlType": "DOMString"

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc