Add node_modules

This commit is contained in:
Anton Medvedev 2023-01-10 16:49:41 +01:00
commit 554eb0b122
994 changed files with 195567 additions and 0 deletions

View file

@ -0,0 +1,2 @@
# node-domexception
An implementation of the DOMException class from NodeJS

View file

@ -0,0 +1,41 @@
# DOMException
An implementation of the DOMException class from NodeJS
This package implements the [`DOMException`](https://developer.mozilla.org/en-US/docs/Web/API/DOMException) class, from NodeJS itself.
NodeJS has DOMException built in, but it's not globally available, and you can't require/import it from somewhere.
The only possible way is to use some web-ish tools that have been introduced into NodeJS that throws an error and catch the constructor.
This way you will have the same class that NodeJS has and you can check if the error is a instance of DOMException.
The instanceof check would not have worked with a custom class such as the DOMexception provided by domenic which also is much larger in size.
```js
import DOMException from 'node-domexception'
hello().catch(err => {
if (err instanceof DOMException) {
...
}
})
const e1 = new DOMException("Something went wrong", "BadThingsError");
console.assert(e1.name === "BadThingsError");
console.assert(e1.code === 0);
const e2 = new DOMException("Another exciting error message", "NoModificationAllowedError");
console.assert(e2.name === "NoModificationAllowedError");
console.assert(e2.code === 7);
console.assert(DOMException.INUSE_ATTRIBUTE_ERR === 10);
```
## APIs
This package exposes two flavors of the `DOMException` interface depending on the imported module.
### `domexception` module
This module default-exports the `DOMException` interface constructor.
### `domexception/webidl2js-wrapper` module
This module exports the `DOMException` [interface wrapper API](https://github.com/jsdom/webidl2js#for-interfaces) generated by [webidl2js](https://github.com/jsdom/webidl2js).

View file

@ -0,0 +1,36 @@
# DOMException
An implementation of the DOMException class from NodeJS
This package implements the [`DOMException`](https://developer.mozilla.org/en-US/docs/Web/API/DOMException) class, from NodeJS itself. (including the legacy codes)
NodeJS has DOMException built in, but it's not globally available, and you can't require/import it from somewhere.
The only possible way is to use some web-ish tools that have been introduced into NodeJS that throws an error and catch the constructor.
This way you will have the same class that NodeJS has and you can check if the error is a instance of DOMException.
The instanceof check would not have worked with a custom class such as the DOMException provided by domenic which also is much larger in size.
```js
import DOMException from 'node-domexception'
import { MessageChannel } from 'worker_threads'
async function hello() {
const port = new MessageChannel().port1
const ab = new ArrayBuffer()
port.postMessage(ab, [ab, ab])
}
hello().catch(err => {
console.assert(err.name === 'DataCloneError')
console.assert(err.code === 25)
console.assert(err instanceof DOMException)
})
const e1 = new DOMException('Something went wrong', 'BadThingsError')
console.assert(e1.name === 'BadThingsError')
console.assert(e1.code === 0)
const e2 = new DOMException('Another exciting error message', 'NoModificationAllowedError')
console.assert(e2.name === 'NoModificationAllowedError')
console.assert(e2.code === 7)
console.assert(DOMException.INUSE_ATTRIBUTE_ERR === 10)
```

View file

@ -0,0 +1,36 @@
# DOMException
An implementation of the DOMException class from NodeJS
This package implements the [`DOMException`](https://developer.mozilla.org/en-US/docs/Web/API/DOMException) class that comes from NodeJS itself. (including the legacy codes)
NodeJS has DOMException built in, but it's not globally available, and you can't require/import it from somewhere.
The only possible way is to use some web-ish tools that have been introduced into NodeJS that throws an error and catch the constructor.
This way you will have the same class that NodeJS has and you can check if the error is a instance of DOMException.
The instanceof check would not have worked with a custom class such as the DOMException provided by domenic which also is much larger in size.
```js
import DOMException from 'node-domexception'
import { MessageChannel } from 'worker_threads'
async function hello() {
const port = new MessageChannel().port1
const ab = new ArrayBuffer()
port.postMessage(ab, [ab, ab])
}
hello().catch(err => {
console.assert(err.name === 'DataCloneError')
console.assert(err.code === 25)
console.assert(err instanceof DOMException)
})
const e1 = new DOMException('Something went wrong', 'BadThingsError')
console.assert(e1.name === 'BadThingsError')
console.assert(e1.code === 0)
const e2 = new DOMException('Another exciting error message', 'NoModificationAllowedError')
console.assert(e2.name === 'NoModificationAllowedError')
console.assert(e2.code === 7)
console.assert(DOMException.INUSE_ATTRIBUTE_ERR === 10)
```

View file

@ -0,0 +1,36 @@
# DOMException
An implementation of the DOMException class from NodeJS
This package exposes the [`DOMException`](https://developer.mozilla.org/en-US/docs/Web/API/DOMException) class that comes from NodeJS itself. (including all of the deprecated legacy codes)
NodeJS has it built in, but it's not globally available, and you can't require/import it from somewhere.
The only possible way is to use some web-ish tools that have been introduced into NodeJS that throws an error and catch the constructor.
This way you will have the same class that NodeJS has and you can check if the error is a instance of DOMException.
The instanceof check would not have worked with a custom class such as the DOMException provided by domenic which also is much larger in size since it has to re-construct the hole class from the ground up.
```js
import DOMException from 'node-domexception'
import { MessageChannel } from 'worker_threads'
async function hello() {
const port = new MessageChannel().port1
const ab = new ArrayBuffer()
port.postMessage(ab, [ab, ab])
}
hello().catch(err => {
console.assert(err.name === 'DataCloneError')
console.assert(err.code === 25)
console.assert(err instanceof DOMException)
})
const e1 = new DOMException('Something went wrong', 'BadThingsError')
console.assert(e1.name === 'BadThingsError')
console.assert(e1.code === 0)
const e2 = new DOMException('Another exciting error message', 'NoModificationAllowedError')
console.assert(e2.name === 'NoModificationAllowedError')
console.assert(e2.code === 7)
console.assert(DOMException.INUSE_ATTRIBUTE_ERR === 10)
```

View file

@ -0,0 +1,38 @@
# DOMException
An implementation of the DOMException class from NodeJS
This package exposes the [`DOMException`](https://developer.mozilla.org/en-US/docs/Web/API/DOMException) class that comes from NodeJS itself. (including all of the deprecated legacy codes)
NodeJS has it built in, but it's not globally available, and you can't require/import it from somewhere.
The only possible way is to use some web-ish tools that have been introduced into NodeJS that throws an error and catch the constructor.
This way you will have the same class that NodeJS has and you can check if the error is a instance of DOMException.
The instanceof check would not have worked with a custom class such as the DOMException provided by domenic which also is much larger in size since it has to re-construct the hole class from the ground up.
(plz don't depend on this package in any other environment other than node >=10.5)
```js
import DOMException from 'node-domexception'
import { MessageChannel } from 'worker_threads'
async function hello() {
const port = new MessageChannel().port1
const ab = new ArrayBuffer()
port.postMessage(ab, [ab, ab])
}
hello().catch(err => {
console.assert(err.name === 'DataCloneError')
console.assert(err.code === 25)
console.assert(err instanceof DOMException)
})
const e1 = new DOMException('Something went wrong', 'BadThingsError')
console.assert(e1.name === 'BadThingsError')
console.assert(e1.code === 0)
const e2 = new DOMException('Another exciting error message', 'NoModificationAllowedError')
console.assert(e2.name === 'NoModificationAllowedError')
console.assert(e2.code === 7)
console.assert(DOMException.INUSE_ATTRIBUTE_ERR === 10)
```

View file

@ -0,0 +1,38 @@
# DOMException
An implementation of the DOMException class from NodeJS
This package exposes the [`DOMException`](https://developer.mozilla.org/en-US/docs/Web/API/DOMException) class that comes from NodeJS itself. (including all of the deprecated legacy codes)
NodeJS has it built in, but it's not globally available, and you can't require/import it from somewhere.
The only possible way is to use some web-ish tools that have been introduced into NodeJS that throws an error and catch the constructor.
This way you will have the same class that NodeJS has and you can check if the error is a instance of DOMException.
The instanceof check would not have worked with a custom class such as the DOMException provided by domenic which also is much larger in size since it has to re-construct the hole class from the ground up.
(plz don't depend on this package in any other environment other than node >=10.5)
```js
import DOMException from 'node-domexception'
import { MessageChannel } from 'worker_threads'
async function hello() {
const port = new MessageChannel().port1
const ab = new ArrayBuffer()
port.postMessage(ab, [ab, ab])
}
hello().catch(err => {
console.assert(err.name === 'DataCloneError')
console.assert(err.code === 25)
console.assert(err instanceof DOMException)
})
const e1 = new DOMException('Something went wrong', 'BadThingsError')
console.assert(e1.name === 'BadThingsError')
console.assert(e1.code === 0)
const e2 = new DOMException('Another exciting error message', 'NoModificationAllowedError')
console.assert(e2.name === 'NoModificationAllowedError')
console.assert(e2.code === 7)
console.assert(DOMException.INUSE_ATTRIBUTE_ERR === 10)
```

View file

View file

@ -0,0 +1,8 @@
const { MessageChannel } = require('worker_threads')
if (!globalThis.DOMException) {
const port = new MessageChannel().port1
const ab = new ArrayBuffer()
try { port.postMessage(ab, [ab, ab]) }
catch (err) { globalThis.DOMException = err.constructor }
}

View file

@ -0,0 +1,9 @@
if (!globalThis.DOMException) {
const { MessageChannel } = require('worker_threads')
const port = new MessageChannel().port1
const ab = new ArrayBuffer()
try { port.postMessage(ab, [ab, ab]) }
catch (err) { globalThis.DOMException = err.constructor }
}
module.exports

View file

@ -0,0 +1,9 @@
if (!globalThis.DOMException) {
const { MessageChannel } = require('worker_threads')
const port = new MessageChannel().port1
const ab = new ArrayBuffer()
try { port.postMessage(ab, [ab, ab]) }
catch (err) { globalThis.DOMException = err.constructor }
}
module.exports = globalThis.DOMException

View file

@ -0,0 +1,11 @@
/*! blob-to-buffer. MIT License. Jimmy Wärting <https://jimmy.warting.se> */
if (!globalThis.DOMException) {
const { MessageChannel } = require('worker_threads')
const port = new MessageChannel().port1
const ab = new ArrayBuffer()
try { port.postMessage(ab, [ab, ab]) }
catch (err) { globalThis.DOMException = err.constructor }
}
module.exports = globalThis.DOMException

View file

@ -0,0 +1,11 @@
/*! blob-to-buffer. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
if (!globalThis.DOMException) {
const { MessageChannel } = require('worker_threads')
const port = new MessageChannel().port1
const ab = new ArrayBuffer()
try { port.postMessage(ab, [ab, ab]) }
catch (err) { globalThis.DOMException = err.constructor }
}
module.exports = globalThis.DOMException

View file

@ -0,0 +1,15 @@
/*! blob-to-buffer. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
if (!globalThis.DOMException) {
var { MessageChannel } = require('worker_threads'),
port = new MessageChannel().port1,
ab = new ArrayBuffer()
try { port.postMessage(ab, [ab, ab]) }
catch (err) {
err.constructor.name === 'DOMException' && (
globalThis.DOMException = err.constructor
)
}
}
module.exports = globalThis.DOMException

View file

@ -0,0 +1,15 @@
/*! blob-to-buffer. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
if (!globalThis.DOMException) {
const { MessageChannel } = require('worker_threads'),
port = new MessageChannel().port1,
ab = new ArrayBuffer()
try { port.postMessage(ab, [ab, ab]) }
catch (err) {
err.constructor.name === 'DOMException' && (
globalThis.DOMException = err.constructor
)
}
}
module.exports = globalThis.DOMException

View file

@ -0,0 +1,23 @@
/*! blob-to-buffer. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
if (!globalThis.DOMException) {
const { MessageChannel } = require('worker_threads'),
port = new MessageChannel().port1,
ab = new ArrayBuffer()
try { port.postMessage(ab, [ab, ab]) }
catch (err) {
err.constructor.name === 'DOMException' && (
globalThis.DOMException = err.constructor
)
}
}
module.exports = globalThis.DOMException
const e1 = new DOMException("Something went wrong", "BadThingsError");
console.assert(e1.name === "BadThingsError");
console.assert(e1.code === 0);
const e2 = new DOMException("Another exciting error message", "NoModificationAllowedError");
console.assert(e2.name === "NoModificationAllowedError");
console.assert(e2.code === 7);

View file

@ -0,0 +1,23 @@
/*! blob-to-buffer. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
if (!globalThis.DOMException) {
const { MessageChannel } = require('worker_threads'),
port = new MessageChannel().port1,
ab = new ArrayBuffer()
try { port.postMessage(ab, [ab, ab]) }
catch (err) {
err.constructor.name === 'DOMException' && (
globalThis.DOMException = err.constructor
)
}
}
module.exports = globalThis.DOMException
const e1 = new DOMException("Something went wrong", "BadThingsError");
console.assert(e1.name === "BadThingsError");
console.assert(e1.code === 0);
const e2 = new DOMException("Another exciting error message", "NoModificationAllowedError");
console.assert(e2.name === "NoModificationAllowedError");
console.assert(e2.code === 2);

View file

@ -0,0 +1,15 @@
/*! blob-to-buffer. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
if (!globalThis.DOMException) {
const { MessageChannel } = require('worker_threads'),
port = new MessageChannel().port1,
ab = new ArrayBuffer()
try { port.postMessage(ab, [ab, ab]) }
catch (err) {
err.constructor.name === 'DOMException' && (
globalThis.DOMException = err.constructor
)
}
}
module.exports = globalThis.DOMException

View file

@ -0,0 +1,16 @@
/*! blob-to-buffer. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
if (!globalThis.DOMException) {
const { MessageChannel } = require('worker_threads'),
port = new MessageChannel().port1,
ab = new ArrayBuffer()
try { port.postMessage(ab, [ab, ab]) }
catch (err) {
console.log(err.code)
err.constructor.name === 'DOMException' && (
globalThis.DOMException = err.constructor
)
}
}
module.exports = globalThis.DOMException

View file

@ -0,0 +1,16 @@
/*! blob-to-buffer. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
if (!globalThis.DOMException) {
const { MessageChannel } = require('worker_threads'),
port = new MessageChannel().port1,
ab = new ArrayBuffer()
try { port.postMessage(ab, [ab, ab]) }
catch (err) {
console.log(err.code, err.name, err.message)
err.constructor.name === 'DOMException' && (
globalThis.DOMException = err.constructor
)
}
}
module.exports = globalThis.DOMException

View file

@ -0,0 +1,16 @@
/*! node-DOMException. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
if (!globalThis.DOMException) {
const { MessageChannel } = require('worker_threads'),
port = new MessageChannel().port1,
ab = new ArrayBuffer()
try { port.postMessage(ab, [ab, ab]) }
catch (err) {
console.log(err.code, err.name, err.message)
err.constructor.name === 'DOMException' && (
globalThis.DOMException = err.constructor
)
}
}
module.exports = globalThis.DOMException

View file

@ -0,0 +1,17 @@
/*! node-DOMException. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
if (!globalThis.DOMException) {
try {
const { MessageChannel } = require('worker_threads'),
port = new MessageChannel().port1,
ab = new ArrayBuffer()
port.postMessage(ab, [ab, ab])
catch (err) {
console.log(err.code, err.name, err.message)
err.constructor.name === 'DOMException' && (
globalThis.DOMException = err.constructor
)
}
}
module.exports = globalThis.DOMException

View file

@ -0,0 +1,17 @@
/*! node-DOMException. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
if (!globalThis.DOMException) {
try {
const { MessageChannel } = require('worker_threads'),
port = new MessageChannel().port1,
ab = new ArrayBuffer()
port.postMessage(ab, [ab, ab])
} catch (err) {
console.log(err.code, err.name, err.message)
err.constructor.name === 'DOMException' && (
globalThis.DOMException = err.constructor
)
}
}
module.exports = globalThis.DOMException

View file

@ -0,0 +1,16 @@
/*! node-DOMException. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
if (!globalThis.DOMException) {
try {
const { MessageChannel } = require('worker_threads'),
port = new MessageChannel().port1,
ab = new ArrayBuffer()
port.postMessage(ab, [ab, ab])
} catch (err) {
err.constructor.name === 'DOMException' && (
globalThis.DOMException = err.constructor
)
}
}
module.exports = globalThis.DOMException

View file

@ -0,0 +1,16 @@
/*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
if (!globalThis.DOMException) {
try {
const { MessageChannel } = require('worker_threads'),
port = new MessageChannel().port1,
ab = new ArrayBuffer()
port.postMessage(ab, [ab, ab])
} catch (err) {
err.constructor.name === 'DOMException' && (
globalThis.DOMException = err.constructor
)
}
}
module.exports = globalThis.DOMException

View file

@ -0,0 +1,41 @@
/*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
if (!globalThis.DOMException) {
try {
const { MessageChannel } = require('worker_threads'),
port = new MessageChannel().port1,
ab = new ArrayBuffer()
port.postMessage(ab, [ab, ab])
} catch (err) {
err.constructor.name === 'DOMException' && (
globalThis.DOMException = err.constructor
)
}
}
module.exports = globalThis.DOMException
const { MessageChannel } = require('worker_threads')
async function hello() {
const port = new MessageChannel().port1
const ab = new ArrayBuffer()
port.postMessage(ab, [ab, ab])
}
hello().catch(err => {
console.assert(err.name === 'DataCloneError')
console.assert(err.code === 25)
console.assert(err instanceof DOMException)
})
const e1 = new DOMException('Something went wrong', 'BadThingsError')
console.assert(e1.name === 'BadThingsError')
console.assert(e1.code === 0)
const e2 = new DOMException('Another exciting error message', 'NoModificationAllowedError')
console.assert(e2.name === 'NoModificationAllowedError')
console.assert(e2.code === 7)
console.assert(DOMException.INUSE_ATTRIBUTE_ERR === 10)

View file

@ -0,0 +1,41 @@
/*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
if (!globalThis.DOMException) {
try {
const { MessageChannel } = require('worker_threads'),
port = new MessageChannel().port1,
ab = new ArrayBuffer()
port.postMessage(ab, [ab, ab])
} catch (err) {
err.constructor.name === 'DOMException' && (
globalThis.DOMException = err.constructor
)
}
}
module.exports = globalThis.DOMException
const { MessageChannel } = require('worker_threads')
async function hello() {
const port = new MessageChannel().port1
const ab = new ArrayBuffer()
port.postMessage(ab, [ab, ab])
}
hello().catch(err => {
console.assert(err.name === 'DataCloneError')
console.assert(err.code === 21)
console.assert(err instanceof DOMException)
})
const e1 = new DOMException('Something went wrong', 'BadThingsError')
console.assert(e1.name === 'BadThingsError')
console.assert(e1.code === 0)
const e2 = new DOMException('Another exciting error message', 'NoModificationAllowedError')
console.assert(e2.name === 'NoModificationAllowedError')
console.assert(e2.code === 7)
console.assert(DOMException.INUSE_ATTRIBUTE_ERR === 10)

View file

@ -0,0 +1,16 @@
/*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
if (!globalThis.DOMException) {
try {
const { MessageChannel } = require('worker_threads'),
port = new MessageChannel().port1,
ab = new ArrayBuffer()
port.postMessage(ab, [ab, ab])
} catch (err) {
err.constructor.name === 'DOMException' && (
globalThis.DOMException = err.constructor
)
}
}
module.exports = globalThis.DOMException

View file

@ -0,0 +1,19 @@
{
"name": "domexception",
"version": "1.0.0",
"description": "An implementation of the DOMException class from NodeJS",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jimmywarting/node-domexception.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/jimmywarting/node-domexception/issues"
},
"homepage": "https://github.com/jimmywarting/node-domexception#readme"
}

View file

@ -0,0 +1,16 @@
{
"name": "node-domexception",
"version": "1.0.0",
"description": "An implementation of the DOMException class from NodeJS",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/jimmywarting/node-domexception.git"
},
"author": "Jimmy Wärting",
"license": "MIT",
"bugs": {
"url": "https://github.com/jimmywarting/node-domexception/issues"
},
"homepage": "https://github.com/jimmywarting/node-domexception#readme"
}

View file

@ -0,0 +1,19 @@
{
"name": "node-domexception",
"version": "1.0.0",
"description": "An implementation of the DOMException class from NodeJS",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/jimmywarting/node-domexception.git"
},
"engines": {
"node": ">=10.5.0"
},
"author": "Jimmy Wärting",
"license": "MIT",
"bugs": {
"url": "https://github.com/jimmywarting/node-domexception/issues"
},
"homepage": "https://github.com/jimmywarting/node-domexception#readme"
}

View file

@ -0,0 +1,25 @@
{
"name": "node-domexception",
"version": "1.0.0",
"description": "An implementation of the DOMException class from NodeJS",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/jimmywarting/node-domexception.git"
},
"engines": {
"node": ">=10.5.0"
},
"author": "Jimmy Wärting",
"license": "MIT",
"bugs": {
"url": "https://github.com/jimmywarting/node-domexception/issues"
},
"homepage": "https://github.com/jimmywarting/node-domexception#readme",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
}
]
}

View file

@ -0,0 +1,25 @@
{
"name": "node-domexception",
"version": "1.0.0",
"description": "An implementation of the DOMException class from NodeJS",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/jimmywarting/node-domexception.git"
},
"engines": {
"node": ">=10.5.0"
},
"author": "Jimmy Wärting",
"license": "MIT",
"bugs": {
"url": "https://github.com/jimmywarting/node-domexception/issues"
},
"homepage": "https://github.com/jimmywarting/node-domexception#readme",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
}
]
}

View file

@ -0,0 +1,29 @@
{
"name": "node-domexception",
"version": "1.0.0",
"description": "An implementation of the DOMException class from NodeJS",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/jimmywarting/node-domexception.git"
},
"engines": {
"node": ">=10.5.0"
},
"author": "Jimmy Wärting",
"license": "MIT",
"bugs": {
"url": "https://github.com/jimmywarting/node-domexception/issues"
},
"homepage": "https://github.com/jimmywarting/node-domexception#readme",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
},
{
"type": "github",
"url": "https://paypal.me/jimmywarting"
}
]
}

View file

@ -0,0 +1,29 @@
{
"name": "node-domexception",
"version": "1.0.0",
"description": "An implementation of the DOMException class from NodeJS",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/jimmywarting/node-domexception.git"
},
"engines": {
"node": ">=10.5.0"
},
"author": "Jimmy Wärting",
"license": "MIT",
"bugs": {
"url": "https://github.com/jimmywarting/node-domexception/issues"
},
"homepage": "https://github.com/jimmywarting/node-domexception#readme",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
},
{
"type": "github",
"url": "https://paypal.me/jimmywarting"
}
]
}

View file

View file

@ -0,0 +1,3 @@
require('./index.js')
console.log(DOMException.INDEX_SIZE_ERR)

View file

@ -0,0 +1,3 @@
const e = require('./index.js')
console.log(e.INDEX_SIZE_ERR)

21
node_modules/node-domexception/LICENSE generated vendored Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Jimmy Wärting
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

46
node_modules/node-domexception/README.md generated vendored Normal file
View file

@ -0,0 +1,46 @@
# DOMException
An implementation of the DOMException class from NodeJS
NodeJS has DOMException built in, but it's not globally available, and you can't require/import it from somewhere.
This package exposes the [`DOMException`](https://developer.mozilla.org/en-US/docs/Web/API/DOMException) class that comes from NodeJS itself. (including all of the legacy codes)
<sub>(plz don't depend on this package in any other environment other than node >=10.5)</sub>
```js
import DOMException from 'node-domexception'
import { MessageChannel } from 'worker_threads'
async function hello() {
const port = new MessageChannel().port1
const ab = new ArrayBuffer()
port.postMessage(ab, [ab, ab])
}
hello().catch(err => {
console.assert(err.name === 'DataCloneError')
console.assert(err.code === 25)
console.assert(err instanceof DOMException)
})
const e1 = new DOMException('Something went wrong', 'BadThingsError')
console.assert(e1.name === 'BadThingsError')
console.assert(e1.code === 0)
const e2 = new DOMException('Another exciting error message', 'NoModificationAllowedError')
console.assert(e2.name === 'NoModificationAllowedError')
console.assert(e2.code === 7)
console.assert(DOMException.INUSE_ATTRIBUTE_ERR === 10)
```
# Background
The only possible way is to use some web-ish tools that have been introduced into NodeJS that throws a DOMException and catch the constructor. This is exactly what this package dose for you and exposes it.<br>
This way you will have the same class that NodeJS has and you can check if the error is a instance of DOMException.<br>
The instanceof check would not have worked with a custom class such as the DOMException provided by domenic which also is much larger in size since it has to re-construct the hole class from the ground up.
The DOMException is used in many places such as the Fetch API, File & Blobs, PostMessaging and more. <br>
Why they decided to call it **DOM**, I don't know
Please consider sponsoring if you find this helpful

16
node_modules/node-domexception/index.js generated vendored Normal file
View file

@ -0,0 +1,16 @@
/*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
if (!globalThis.DOMException) {
try {
const { MessageChannel } = require('worker_threads'),
port = new MessageChannel().port1,
ab = new ArrayBuffer()
port.postMessage(ab, [ab, ab])
} catch (err) {
err.constructor.name === 'DOMException' && (
globalThis.DOMException = err.constructor
)
}
}
module.exports = globalThis.DOMException

29
node_modules/node-domexception/package.json generated vendored Normal file
View file

@ -0,0 +1,29 @@
{
"name": "node-domexception",
"version": "1.0.0",
"description": "An implementation of the DOMException class from NodeJS",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/jimmywarting/node-domexception.git"
},
"engines": {
"node": ">=10.5.0"
},
"author": "Jimmy Wärting",
"license": "MIT",
"bugs": {
"url": "https://github.com/jimmywarting/node-domexception/issues"
},
"homepage": "https://github.com/jimmywarting/node-domexception#readme",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
},
{
"type": "github",
"url": "https://paypal.me/jimmywarting"
}
]
}