summaryrefslogtreecommitdiffstats
path: root/debian/tests/test_modules/abort-controller
diff options
context:
space:
mode:
Diffstat (limited to 'debian/tests/test_modules/abort-controller')
-rw-r--r--debian/tests/test_modules/abort-controller/LICENSE21
-rw-r--r--debian/tests/test_modules/abort-controller/browser.js13
-rw-r--r--debian/tests/test_modules/abort-controller/browser.mjs11
-rw-r--r--debian/tests/test_modules/abort-controller/dist/abort-controller.d.ts43
-rw-r--r--debian/tests/test_modules/abort-controller/dist/abort-controller.js127
-rw-r--r--debian/tests/test_modules/abort-controller/dist/abort-controller.mjs118
-rw-r--r--debian/tests/test_modules/abort-controller/package.json97
-rw-r--r--debian/tests/test_modules/abort-controller/polyfill.js21
-rw-r--r--debian/tests/test_modules/abort-controller/polyfill.mjs19
9 files changed, 470 insertions, 0 deletions
diff --git a/debian/tests/test_modules/abort-controller/LICENSE b/debian/tests/test_modules/abort-controller/LICENSE
new file mode 100644
index 0000000..c914149
--- /dev/null
+++ b/debian/tests/test_modules/abort-controller/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2017 Toru Nagashima
+
+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.
diff --git a/debian/tests/test_modules/abort-controller/browser.js b/debian/tests/test_modules/abort-controller/browser.js
new file mode 100644
index 0000000..b0c5ec3
--- /dev/null
+++ b/debian/tests/test_modules/abort-controller/browser.js
@@ -0,0 +1,13 @@
+/*globals self, window */
+"use strict"
+
+/*eslint-disable @mysticatea/prettier */
+const { AbortController, AbortSignal } =
+ typeof self !== "undefined" ? self :
+ typeof window !== "undefined" ? window :
+ /* otherwise */ undefined
+/*eslint-enable @mysticatea/prettier */
+
+module.exports = AbortController
+module.exports.AbortSignal = AbortSignal
+module.exports.default = AbortController
diff --git a/debian/tests/test_modules/abort-controller/browser.mjs b/debian/tests/test_modules/abort-controller/browser.mjs
new file mode 100644
index 0000000..a8f321a
--- /dev/null
+++ b/debian/tests/test_modules/abort-controller/browser.mjs
@@ -0,0 +1,11 @@
+/*globals self, window */
+
+/*eslint-disable @mysticatea/prettier */
+const { AbortController, AbortSignal } =
+ typeof self !== "undefined" ? self :
+ typeof window !== "undefined" ? window :
+ /* otherwise */ undefined
+/*eslint-enable @mysticatea/prettier */
+
+export default AbortController
+export { AbortController, AbortSignal }
diff --git a/debian/tests/test_modules/abort-controller/dist/abort-controller.d.ts b/debian/tests/test_modules/abort-controller/dist/abort-controller.d.ts
new file mode 100644
index 0000000..75852fb
--- /dev/null
+++ b/debian/tests/test_modules/abort-controller/dist/abort-controller.d.ts
@@ -0,0 +1,43 @@
+import { EventTarget } from "event-target-shim"
+
+type Events = {
+ abort: any
+}
+type EventAttributes = {
+ onabort: any
+}
+/**
+ * The signal class.
+ * @see https://dom.spec.whatwg.org/#abortsignal
+ */
+declare class AbortSignal extends EventTarget<Events, EventAttributes> {
+ /**
+ * AbortSignal cannot be constructed directly.
+ */
+ constructor()
+ /**
+ * Returns `true` if this `AbortSignal`"s `AbortController` has signaled to abort, and `false` otherwise.
+ */
+ readonly aborted: boolean
+}
+/**
+ * The AbortController.
+ * @see https://dom.spec.whatwg.org/#abortcontroller
+ */
+declare class AbortController {
+ /**
+ * Initialize this controller.
+ */
+ constructor()
+ /**
+ * Returns the `AbortSignal` object associated with this object.
+ */
+ readonly signal: AbortSignal
+ /**
+ * Abort and signal to any observers that the associated activity is to be aborted.
+ */
+ abort(): void
+}
+
+export default AbortController
+export { AbortController, AbortSignal }
diff --git a/debian/tests/test_modules/abort-controller/dist/abort-controller.js b/debian/tests/test_modules/abort-controller/dist/abort-controller.js
new file mode 100644
index 0000000..49af739
--- /dev/null
+++ b/debian/tests/test_modules/abort-controller/dist/abort-controller.js
@@ -0,0 +1,127 @@
+/**
+ * @author Toru Nagashima <https://github.com/mysticatea>
+ * See LICENSE file in root directory for full license.
+ */
+'use strict';
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+var eventTargetShim = require('event-target-shim');
+
+/**
+ * The signal class.
+ * @see https://dom.spec.whatwg.org/#abortsignal
+ */
+class AbortSignal extends eventTargetShim.EventTarget {
+ /**
+ * AbortSignal cannot be constructed directly.
+ */
+ constructor() {
+ super();
+ throw new TypeError("AbortSignal cannot be constructed directly");
+ }
+ /**
+ * Returns `true` if this `AbortSignal`'s `AbortController` has signaled to abort, and `false` otherwise.
+ */
+ get aborted() {
+ const aborted = abortedFlags.get(this);
+ if (typeof aborted !== "boolean") {
+ throw new TypeError(`Expected 'this' to be an 'AbortSignal' object, but got ${this === null ? "null" : typeof this}`);
+ }
+ return aborted;
+ }
+}
+eventTargetShim.defineEventAttribute(AbortSignal.prototype, "abort");
+/**
+ * Create an AbortSignal object.
+ */
+function createAbortSignal() {
+ const signal = Object.create(AbortSignal.prototype);
+ eventTargetShim.EventTarget.call(signal);
+ abortedFlags.set(signal, false);
+ return signal;
+}
+/**
+ * Abort a given signal.
+ */
+function abortSignal(signal) {
+ if (abortedFlags.get(signal) !== false) {
+ return;
+ }
+ abortedFlags.set(signal, true);
+ signal.dispatchEvent({ type: "abort" });
+}
+/**
+ * Aborted flag for each instances.
+ */
+const abortedFlags = new WeakMap();
+// Properties should be enumerable.
+Object.defineProperties(AbortSignal.prototype, {
+ aborted: { enumerable: true },
+});
+// `toString()` should return `"[object AbortSignal]"`
+if (typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol") {
+ Object.defineProperty(AbortSignal.prototype, Symbol.toStringTag, {
+ configurable: true,
+ value: "AbortSignal",
+ });
+}
+
+/**
+ * The AbortController.
+ * @see https://dom.spec.whatwg.org/#abortcontroller
+ */
+class AbortController {
+ /**
+ * Initialize this controller.
+ */
+ constructor() {
+ signals.set(this, createAbortSignal());
+ }
+ /**
+ * Returns the `AbortSignal` object associated with this object.
+ */
+ get signal() {
+ return getSignal(this);
+ }
+ /**
+ * Abort and signal to any observers that the associated activity is to be aborted.
+ */
+ abort() {
+ abortSignal(getSignal(this));
+ }
+}
+/**
+ * Associated signals.
+ */
+const signals = new WeakMap();
+/**
+ * Get the associated signal of a given controller.
+ */
+function getSignal(controller) {
+ const signal = signals.get(controller);
+ if (signal == null) {
+ throw new TypeError(`Expected 'this' to be an 'AbortController' object, but got ${controller === null ? "null" : typeof controller}`);
+ }
+ return signal;
+}
+// Properties should be enumerable.
+Object.defineProperties(AbortController.prototype, {
+ signal: { enumerable: true },
+ abort: { enumerable: true },
+});
+if (typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol") {
+ Object.defineProperty(AbortController.prototype, Symbol.toStringTag, {
+ configurable: true,
+ value: "AbortController",
+ });
+}
+
+exports.AbortController = AbortController;
+exports.AbortSignal = AbortSignal;
+exports.default = AbortController;
+
+module.exports = AbortController
+module.exports.AbortController = module.exports["default"] = AbortController
+module.exports.AbortSignal = AbortSignal
+//# sourceMappingURL=abort-controller.js.map
diff --git a/debian/tests/test_modules/abort-controller/dist/abort-controller.mjs b/debian/tests/test_modules/abort-controller/dist/abort-controller.mjs
new file mode 100644
index 0000000..88ba22d
--- /dev/null
+++ b/debian/tests/test_modules/abort-controller/dist/abort-controller.mjs
@@ -0,0 +1,118 @@
+/**
+ * @author Toru Nagashima <https://github.com/mysticatea>
+ * See LICENSE file in root directory for full license.
+ */
+import { EventTarget, defineEventAttribute } from 'event-target-shim';
+
+/**
+ * The signal class.
+ * @see https://dom.spec.whatwg.org/#abortsignal
+ */
+class AbortSignal extends EventTarget {
+ /**
+ * AbortSignal cannot be constructed directly.
+ */
+ constructor() {
+ super();
+ throw new TypeError("AbortSignal cannot be constructed directly");
+ }
+ /**
+ * Returns `true` if this `AbortSignal`'s `AbortController` has signaled to abort, and `false` otherwise.
+ */
+ get aborted() {
+ const aborted = abortedFlags.get(this);
+ if (typeof aborted !== "boolean") {
+ throw new TypeError(`Expected 'this' to be an 'AbortSignal' object, but got ${this === null ? "null" : typeof this}`);
+ }
+ return aborted;
+ }
+}
+defineEventAttribute(AbortSignal.prototype, "abort");
+/**
+ * Create an AbortSignal object.
+ */
+function createAbortSignal() {
+ const signal = Object.create(AbortSignal.prototype);
+ EventTarget.call(signal);
+ abortedFlags.set(signal, false);
+ return signal;
+}
+/**
+ * Abort a given signal.
+ */
+function abortSignal(signal) {
+ if (abortedFlags.get(signal) !== false) {
+ return;
+ }
+ abortedFlags.set(signal, true);
+ signal.dispatchEvent({ type: "abort" });
+}
+/**
+ * Aborted flag for each instances.
+ */
+const abortedFlags = new WeakMap();
+// Properties should be enumerable.
+Object.defineProperties(AbortSignal.prototype, {
+ aborted: { enumerable: true },
+});
+// `toString()` should return `"[object AbortSignal]"`
+if (typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol") {
+ Object.defineProperty(AbortSignal.prototype, Symbol.toStringTag, {
+ configurable: true,
+ value: "AbortSignal",
+ });
+}
+
+/**
+ * The AbortController.
+ * @see https://dom.spec.whatwg.org/#abortcontroller
+ */
+class AbortController {
+ /**
+ * Initialize this controller.
+ */
+ constructor() {
+ signals.set(this, createAbortSignal());
+ }
+ /**
+ * Returns the `AbortSignal` object associated with this object.
+ */
+ get signal() {
+ return getSignal(this);
+ }
+ /**
+ * Abort and signal to any observers that the associated activity is to be aborted.
+ */
+ abort() {
+ abortSignal(getSignal(this));
+ }
+}
+/**
+ * Associated signals.
+ */
+const signals = new WeakMap();
+/**
+ * Get the associated signal of a given controller.
+ */
+function getSignal(controller) {
+ const signal = signals.get(controller);
+ if (signal == null) {
+ throw new TypeError(`Expected 'this' to be an 'AbortController' object, but got ${controller === null ? "null" : typeof controller}`);
+ }
+ return signal;
+}
+// Properties should be enumerable.
+Object.defineProperties(AbortController.prototype, {
+ signal: { enumerable: true },
+ abort: { enumerable: true },
+});
+if (typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol") {
+ Object.defineProperty(AbortController.prototype, Symbol.toStringTag, {
+ configurable: true,
+ value: "AbortController",
+ });
+}
+
+export default AbortController;
+export { AbortController, AbortSignal };
+//# sourceMappingURL=abort-controller.mjs.map
diff --git a/debian/tests/test_modules/abort-controller/package.json b/debian/tests/test_modules/abort-controller/package.json
new file mode 100644
index 0000000..fc705e0
--- /dev/null
+++ b/debian/tests/test_modules/abort-controller/package.json
@@ -0,0 +1,97 @@
+{
+ "name": "abort-controller",
+ "version": "3.0.0",
+ "description": "An implementation of WHATWG AbortController interface.",
+ "main": "dist/abort-controller",
+ "files": [
+ "dist",
+ "polyfill.*",
+ "browser.*"
+ ],
+ "engines": {
+ "node": ">=6.5"
+ },
+ "dependencies": {
+ "event-target-shim": "^5.0.0"
+ },
+ "browser": "./browser.js",
+ "devDependencies": {
+ "@babel/core": "^7.2.2",
+ "@babel/plugin-transform-modules-commonjs": "^7.2.0",
+ "@babel/preset-env": "^7.3.0",
+ "@babel/register": "^7.0.0",
+ "@mysticatea/eslint-plugin": "^8.0.1",
+ "@mysticatea/spy": "^0.1.2",
+ "@types/mocha": "^5.2.5",
+ "@types/node": "^10.12.18",
+ "assert": "^1.4.1",
+ "codecov": "^3.1.0",
+ "dts-bundle-generator": "^2.0.0",
+ "eslint": "^5.12.1",
+ "karma": "^3.1.4",
+ "karma-chrome-launcher": "^2.2.0",
+ "karma-coverage": "^1.1.2",
+ "karma-firefox-launcher": "^1.1.0",
+ "karma-growl-reporter": "^1.0.0",
+ "karma-ie-launcher": "^1.0.0",
+ "karma-mocha": "^1.3.0",
+ "karma-rollup-preprocessor": "^7.0.0-rc.2",
+ "mocha": "^5.2.0",
+ "npm-run-all": "^4.1.5",
+ "nyc": "^13.1.0",
+ "opener": "^1.5.1",
+ "rimraf": "^2.6.3",
+ "rollup": "^1.1.2",
+ "rollup-plugin-babel": "^4.3.2",
+ "rollup-plugin-babel-minify": "^7.0.0",
+ "rollup-plugin-commonjs": "^9.2.0",
+ "rollup-plugin-node-resolve": "^4.0.0",
+ "rollup-plugin-sourcemaps": "^0.4.2",
+ "rollup-plugin-typescript": "^1.0.0",
+ "rollup-watch": "^4.3.1",
+ "ts-node": "^8.0.1",
+ "type-tester": "^1.0.0",
+ "typescript": "^3.2.4"
+ },
+ "scripts": {
+ "preversion": "npm test",
+ "version": "npm run -s build && git add dist/*",
+ "postversion": "git push && git push --tags",
+ "clean": "rimraf .nyc_output coverage",
+ "coverage": "opener coverage/lcov-report/index.html",
+ "lint": "eslint . --ext .ts",
+ "build": "run-s -s build:*",
+ "build:rollup": "rollup -c",
+ "build:dts": "dts-bundle-generator -o dist/abort-controller.d.ts src/abort-controller.ts && ts-node scripts/fix-dts",
+ "test": "run-s -s lint test:*",
+ "test:mocha": "nyc mocha test/*.ts",
+ "test:karma": "karma start --single-run",
+ "watch": "run-p -s watch:*",
+ "watch:mocha": "mocha test/*.ts --require ts-node/register --watch-extensions ts --watch --growl",
+ "watch:karma": "karma start --watch",
+ "codecov": "codecov"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/mysticatea/abort-controller.git"
+ },
+ "keywords": [
+ "w3c",
+ "whatwg",
+ "event",
+ "events",
+ "abort",
+ "cancel",
+ "abortcontroller",
+ "abortsignal",
+ "controller",
+ "signal",
+ "shim"
+ ],
+ "author": "Toru Nagashima (https://github.com/mysticatea)",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/mysticatea/abort-controller/issues"
+ },
+ "homepage": "https://github.com/mysticatea/abort-controller#readme"
+}
diff --git a/debian/tests/test_modules/abort-controller/polyfill.js b/debian/tests/test_modules/abort-controller/polyfill.js
new file mode 100644
index 0000000..3ca8923
--- /dev/null
+++ b/debian/tests/test_modules/abort-controller/polyfill.js
@@ -0,0 +1,21 @@
+/*globals require, self, window */
+"use strict"
+
+const ac = require("./dist/abort-controller")
+
+/*eslint-disable @mysticatea/prettier */
+const g =
+ typeof self !== "undefined" ? self :
+ typeof window !== "undefined" ? window :
+ typeof global !== "undefined" ? global :
+ /* otherwise */ undefined
+/*eslint-enable @mysticatea/prettier */
+
+if (g) {
+ if (typeof g.AbortController === "undefined") {
+ g.AbortController = ac.AbortController
+ }
+ if (typeof g.AbortSignal === "undefined") {
+ g.AbortSignal = ac.AbortSignal
+ }
+}
diff --git a/debian/tests/test_modules/abort-controller/polyfill.mjs b/debian/tests/test_modules/abort-controller/polyfill.mjs
new file mode 100644
index 0000000..0602a64
--- /dev/null
+++ b/debian/tests/test_modules/abort-controller/polyfill.mjs
@@ -0,0 +1,19 @@
+/*globals self, window */
+import * as ac from "./dist/abort-controller"
+
+/*eslint-disable @mysticatea/prettier */
+const g =
+ typeof self !== "undefined" ? self :
+ typeof window !== "undefined" ? window :
+ typeof global !== "undefined" ? global :
+ /* otherwise */ undefined
+/*eslint-enable @mysticatea/prettier */
+
+if (g) {
+ if (typeof g.AbortController === "undefined") {
+ g.AbortController = ac.AbortController
+ }
+ if (typeof g.AbortSignal === "undefined") {
+ g.AbortSignal = ac.AbortSignal
+ }
+}