package/LICENSE000644 0000002057 3560116604 010271 0ustar00000000 000000 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. package/.history/index_20210527203842.js000644 0000000000 3560116604 014137 0ustar00000000 000000 package/.history/index_20210527203947.js000644 0000000406 3560116604 014157 0ustar00000000 000000 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 } } package/.history/index_20210527204259.js000644 0000000427 3560116604 014157 0ustar00000000 000000 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 package/.history/index_20210527204418.js000644 0000000461 3560116604 014152 0ustar00000000 000000 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 package/.history/index_20210527204756.js000644 0000000600 3560116604 014152 0ustar00000000 000000 /*! blob-to-buffer. MIT License. Jimmy Wärting */ 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 package/.history/index_20210527204833.js000644 0000000613 3560116604 014152 0ustar00000000 000000 /*! blob-to-buffer. MIT License. Jimmy Wärting */ 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 package/.history/index_20210527211208.js000644 0000000676 3560116604 014155 0ustar00000000 000000 /*! blob-to-buffer. MIT License. Jimmy Wärting */ 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 package/.history/index_20210527211248.js000644 0000000700 3560116604 014145 0ustar00000000 000000 /*! blob-to-buffer. MIT License. Jimmy Wärting */ 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 package/.history/index_20210527212722.js000644 0000001414 3560116604 014146 0ustar00000000 000000 /*! blob-to-buffer. MIT License. Jimmy Wärting */ 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); package/.history/index_20210527212731.js000644 0000001414 3560116604 014146 0ustar00000000 000000 /*! blob-to-buffer. MIT License. Jimmy Wärting */ 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); package/.history/index_20210527212746.js000644 0000000700 3560116604 014151 0ustar00000000 000000 /*! blob-to-buffer. MIT License. Jimmy Wärting */ 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 package/.history/index_20210527212900.js000644 0000000732 3560116604 014146 0ustar00000000 000000 /*! blob-to-buffer. MIT License. Jimmy Wärting */ 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 package/.history/index_20210527213022.js000644 0000000761 3560116604 014144 0ustar00000000 000000 /*! blob-to-buffer. MIT License. Jimmy Wärting */ 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 package/.history/index_20210527213822.js000644 0000000764 3560116604 014157 0ustar00000000 000000 /*! node-DOMException. MIT License. Jimmy Wärting */ 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 package/.history/index_20210527213843.js000644 0000000774 3560116604 014163 0ustar00000000 000000 /*! node-DOMException. MIT License. Jimmy Wärting */ 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 package/.history/index_20210527213852.js000644 0000000776 3560116604 014165 0ustar00000000 000000 /*! node-DOMException. MIT License. Jimmy Wärting */ 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 package/.history/index_20210527213910.js000644 0000000715 3560116604 014151 0ustar00000000 000000 /*! node-DOMException. MIT License. Jimmy Wärting */ 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 package/.history/index_20210527214034.js000644 0000000715 3560116604 014147 0ustar00000000 000000 /*! node-domexception. MIT License. Jimmy Wärting */ 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 package/.history/index_20210527214643.js000644 0000002245 3560116604 014155 0ustar00000000 000000 /*! node-domexception. MIT License. Jimmy Wärting */ 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) package/.history/index_20210527214654.js000644 0000002245 3560116604 014157 0ustar00000000 000000 /*! node-domexception. MIT License. Jimmy Wärting */ 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) package/.history/index_20210527214700.js000644 0000000715 3560116604 014147 0ustar00000000 000000 /*! node-domexception. MIT License. Jimmy Wärting */ 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 package/index.js000644 0000000715 3560116604 010730 0ustar00000000 000000 /*! node-domexception. MIT License. Jimmy Wärting */ 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 package/.history/test_20210527205603.js000644 0000000000 3560116604 014004 0ustar00000000 000000 package/.history/test_20210527205957.js000644 0000000100 3560116604 014021 0ustar00000000 000000 require('./index.js') console.log(DOMException.INDEX_SIZE_ERR) package/.history/test_20210527210021.js000644 0000000077 3560116604 014010 0ustar00000000 000000 const e = require('./index.js') console.log(e.INDEX_SIZE_ERR) package/.history/package_20210527203733.json000644 0000001031 3560116604 014764 0ustar00000000 000000 { "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" } package/.history/package_20210527203825.json000644 0000000736 3560116604 015001 0ustar00000000 000000 { "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" } package/.history/package_20210527204621.json000644 0000001011 3560116604 014757 0ustar00000000 000000 { "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" } package/.history/package_20210527204913.json000644 0000001171 3560116604 014772 0ustar00000000 000000 { "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" } ] } package/.history/package_20210527204925.json000644 0000001171 3560116604 014775 0ustar00000000 000000 { "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" } ] } package/.history/package_20210527205145.json000644 0000001314 3560116604 014767 0ustar00000000 000000 { "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" } ] } package/.history/package_20210527205156.json000644 0000001314 3560116604 014771 0ustar00000000 000000 { "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" } ] } package/package.json000644 0000001314 3560116604 011545 0ustar00000000 000000 { "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" } ] } package/.history/README_20210527203617.md000644 0000000114 3560116604 013757 0ustar00000000 000000 # node-domexception An implementation of the DOMException class from NodeJS package/.history/README_20210527212714.md000644 0000003206 3560116604 013762 0ustar00000000 000000 # 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). package/.history/README_20210527213345.md000644 0000002764 3560116604 013773 0ustar00000000 000000 # 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) ``` package/.history/README_20210527213411.md000644 0000002776 3560116604 013770 0ustar00000000 000000 # 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) ``` package/.history/README_20210527213803.md000644 0000003102 3560116604 013755 0ustar00000000 000000 # 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) ``` package/.history/README_20210527214323.md000644 0000003226 3560116604 013762 0ustar00000000 000000 # 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) ``` package/.history/README_20210527214408.md000644 0000003226 3560116604 013766 0ustar00000000 000000 # 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) ``` package/README.md000644 0000003716 3560116604 010546 0ustar00000000 000000 # 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) (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) ``` # 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.
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. The DOMException is used in many places such as the Fetch API, File & Blobs, PostMessaging and more.
Why they decided to call it **DOM**, I don't know Please consider sponsoring if you find this helpful