mysticatea-abort-controller-66ac7b4/000077500000000000000000000000001344763160600175735ustar00rootroot00000000000000mysticatea-abort-controller-66ac7b4/.codecov.yml000066400000000000000000000000151344763160600220120ustar00rootroot00000000000000comment: off mysticatea-abort-controller-66ac7b4/.eslintignore000066400000000000000000000001111344763160600222670ustar00rootroot00000000000000/.nyc_output /coverage /dist /node_modules /test/fixtures !.eslintrc.js mysticatea-abort-controller-66ac7b4/.eslintrc.yml000066400000000000000000000007061344763160600222220ustar00rootroot00000000000000root: true extends: - plugin:@mysticatea/es2018 - plugin:@mysticatea/+node overrides: - files: test/** rules: new-cap: "off" # To reduce size for babel-translation. - files: "*" rules: no-restricted-syntax: - error - ForOfStatement - BinaryExpression[left.operator='typeof'][right.value='object'] prefer-rest-params: "off" prefer-spread: "off" "@mysticatea/prefer-for-of": "off" mysticatea-abort-controller-66ac7b4/.gitattributes000066400000000000000000000000231344763160600224610ustar00rootroot00000000000000* text=auto eol=lf mysticatea-abort-controller-66ac7b4/.gitignore000066400000000000000000000000741344763160600215640ustar00rootroot00000000000000/.nyc_output /coverage /node_modules /npm-debug.log /test.* mysticatea-abort-controller-66ac7b4/.npmrc000066400000000000000000000000231344763160600207060ustar00rootroot00000000000000package-lock=false mysticatea-abort-controller-66ac7b4/.nycrc000066400000000000000000000003331344763160600207110ustar00rootroot00000000000000{ "include": [ "src/**/*.ts" ], "extension": [ ".ts" ], "require": [ "ts-node/register" ], "reporter": [ "lcov", "text" ], "sourceMap": true } mysticatea-abort-controller-66ac7b4/.travis.yml000066400000000000000000000002041344763160600217000ustar00rootroot00000000000000language: node_js node_js: - "6" - "8" - "10" - "11" script: - npm run -s test:mocha after_success: - npm run codecov mysticatea-abort-controller-66ac7b4/.vscode/000077500000000000000000000000001344763160600211345ustar00rootroot00000000000000mysticatea-abort-controller-66ac7b4/.vscode/settings.json000066400000000000000000000001551344763160600236700ustar00rootroot00000000000000{ "eslint.validate": [ "javascript", {"language": "typescript", "autoFix": true} ] } mysticatea-abort-controller-66ac7b4/LICENSE000066400000000000000000000020571344763160600206040ustar00rootroot00000000000000MIT 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. mysticatea-abort-controller-66ac7b4/README.md000066400000000000000000000062271344763160600210610ustar00rootroot00000000000000# abort-controller [![npm version](https://img.shields.io/npm/v/abort-controller.svg)](https://www.npmjs.com/package/abort-controller) [![Downloads/month](https://img.shields.io/npm/dm/abort-controller.svg)](http://www.npmtrends.com/abort-controller) [![Build Status](https://travis-ci.org/mysticatea/abort-controller.svg?branch=master)](https://travis-ci.org/mysticatea/abort-controller) [![Coverage Status](https://codecov.io/gh/mysticatea/abort-controller/branch/master/graph/badge.svg)](https://codecov.io/gh/mysticatea/abort-controller) [![Dependency Status](https://david-dm.org/mysticatea/abort-controller.svg)](https://david-dm.org/mysticatea/abort-controller) An implementation of [WHATWG AbortController interface](https://dom.spec.whatwg.org/#interface-abortcontroller). ```js import AbortController from "abort-controller" const controller = new AbortController() const signal = controller.signal signal.addEventListener("abort", () => { console.log("aborted!") }) controller.abort() ``` > https://jsfiddle.net/1r2994qp/1/ ## 💿 Installation Use [npm](https://www.npmjs.com/) to install then use a bundler. ``` npm install abort-controller ``` Or download from [`dist` directory](./dist). - [dist/abort-controller.mjs](dist/abort-controller.mjs) ... ES modules version. - [dist/abort-controller.js](dist/abort-controller.js) ... Common JS version. - [dist/abort-controller.umd.js](dist/abort-controller.umd.js) ... UMD (Universal Module Definition) version. This is transpiled by [Babel](https://babeljs.io/) for IE 11. ## 📖 Usage ### Basic ```js import AbortController from "abort-controller" // or const AbortController = require("abort-controller") // or UMD version defines a global variable: const AbortController = window.AbortControllerShim ``` If your bundler recognizes `browser` field of `package.json`, the imported `AbortController` is the native one and it doesn't contain shim (even if the native implementation was nothing). If you wanted to polyfill `AbortController` for IE, use `abort-controller/polyfill`. ### Polyfilling Importing `abort-controller/polyfill` assigns the `AbortController` shim to the `AbortController` global variable if the native implementation was nothing. ```js import "abort-controller/polyfill" // or require("abort-controller/polyfill") ``` ### API #### AbortController > https://dom.spec.whatwg.org/#interface-abortcontroller ##### controller.signal The [AbortSignal](https://dom.spec.whatwg.org/#interface-AbortSignal) object which is associated to this controller. ##### controller.abort() Notify `abort` event to listeners that the `signal` has. ## 📰 Changelog - See [GitHub releases](https://github.com/mysticatea/abort-controller/releases). ## 🍻 Contributing Contributing is welcome ❤️ Please use GitHub issues/PRs. ### Development tools - `npm install` installs dependencies for development. - `npm test` runs tests and measures code coverage. - `npm run clean` removes temporary files of tests. - `npm run coverage` opens code coverage of the previous test with your default browser. - `npm run lint` runs ESLint. - `npm run build` generates `dist` codes. - `npm run watch` runs tests on each file change. mysticatea-abort-controller-66ac7b4/browser.js000066400000000000000000000006121344763160600216130ustar00rootroot00000000000000/*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 mysticatea-abort-controller-66ac7b4/browser.mjs000066400000000000000000000005211344763160600217670ustar00rootroot00000000000000/*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 } mysticatea-abort-controller-66ac7b4/karma.conf.js000066400000000000000000000031521344763160600221510ustar00rootroot00000000000000"use strict" const babel = require("rollup-plugin-babel") const commonjs = require("rollup-plugin-commonjs") // const json = require("rollup-plugin-json") const resolve = require("rollup-plugin-node-resolve") const sourcemaps = require("rollup-plugin-sourcemaps") const typescript = require("rollup-plugin-typescript") module.exports = function(config) { config.set({ browsers: ["Chrome", "Firefox", "IE"], files: ["test/index.ts", "test/polyfill.ts"], frameworks: ["mocha"], mime: { "text/javascript": ["ts"], }, reporters: ["progress", "growl"], preprocessors: { "test/*.ts": ["rollup"], }, rollupPreprocessor: { output: { format: "iife", name: "AbortControllerShim", sourcemap: "inline", }, plugins: [ resolve({ browser: true, preferBuiltins: false }), sourcemaps(), commonjs(), typescript({ module: "es2015" }), babel({ babelrc: false, extensions: [".js", ".mjs", ".ts"], include: ["**/*.mjs", "**/*.ts"], presets: [ [ "@babel/env", { modules: false, targets: { ie: "11" }, }, ], ], sourceMaps: true, }), ], }, }) } mysticatea-abort-controller-66ac7b4/package.json000066400000000000000000000055431344763160600220700ustar00rootroot00000000000000{ "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" } mysticatea-abort-controller-66ac7b4/polyfill.js000066400000000000000000000010561344763160600217650ustar00rootroot00000000000000/*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 } } mysticatea-abort-controller-66ac7b4/polyfill.mjs000066400000000000000000000010271344763160600221400ustar00rootroot00000000000000/*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 } } mysticatea-abort-controller-66ac7b4/rollup.config.js000066400000000000000000000045331344763160600227170ustar00rootroot00000000000000import babel from "rollup-plugin-babel" import minify from "rollup-plugin-babel-minify" import resolve from "rollup-plugin-node-resolve" import typescript from "rollup-plugin-typescript" const banner = `/** * @author Toru Nagashima * See LICENSE file in root directory for full license. */` const cjsOutro = `module.exports = AbortController module.exports.AbortController = module.exports["default"] = AbortController module.exports.AbortSignal = AbortSignal ` const umdOutro = `if (typeof module === "undefined" && typeof define === "undefined") { var global = Function("return this")() if (typeof global.AbortController === "undefined") { global.AbortController = AbortController global.AbortSignal = AbortSignal } } ` export default [ { external: ["event-target-shim"], input: "src/abort-controller.ts", output: { banner, file: "dist/abort-controller.mjs", format: "es", sourcemap: true, }, plugins: [typescript({ module: "es2015" })], }, { external: ["event-target-shim"], input: "src/abort-controller.ts", output: { banner, file: "dist/abort-controller.js", format: "cjs", outro: cjsOutro, sourcemap: true, }, plugins: [typescript({ module: "es2015" })], }, { input: "src/abort-controller.ts", output: { file: "dist/abort-controller.umd.js", format: "umd", name: "AbortControllerShim", outro: umdOutro, sourcemap: true, }, plugins: [ resolve(), typescript({ module: "es2015" }), babel({ babelrc: false, extensions: [".mjs", ".ts"], include: ["**/*.mjs", "**/*.ts"], presets: [ [ "@babel/env", { modules: false, targets: { ie: "11" }, }, ], ], sourceMaps: true, }), minify({ comments: false, banner, sourceMap: true, }), ], }, ] mysticatea-abort-controller-66ac7b4/scripts/000077500000000000000000000000001344763160600212625ustar00rootroot00000000000000mysticatea-abort-controller-66ac7b4/scripts/fix-dts.ts000066400000000000000000000010201344763160600232010ustar00rootroot00000000000000import fs from "fs" fs.writeFileSync( "dist/abort-controller.d.ts", [ fs .readFileSync("dist/abort-controller.d.ts", "utf8") .replace(/export declare type/gu, "type") .replace(/export (?:declare|default) class/gu, "declare class") .replace(/\t/gu, " ") .replace(/'/gu, '"') .replace(/;\n/gu, "\n"), "", "export default AbortController", "export { AbortController, AbortSignal }", "", ].join("\n"), ) mysticatea-abort-controller-66ac7b4/src/000077500000000000000000000000001344763160600203625ustar00rootroot00000000000000mysticatea-abort-controller-66ac7b4/src/abort-controller.ts000066400000000000000000000031041344763160600242200ustar00rootroot00000000000000import AbortSignal, { abortSignal, createAbortSignal } from "./abort-signal" /** * The AbortController. * @see https://dom.spec.whatwg.org/#abortcontroller */ export default class AbortController { /** * Initialize this controller. */ public constructor() { signals.set(this, createAbortSignal()) } /** * Returns the `AbortSignal` object associated with this object. */ public get signal(): AbortSignal { return getSignal(this) } /** * Abort and signal to any observers that the associated activity is to be aborted. */ public abort(): void { abortSignal(getSignal(this)) } } /** * Associated signals. */ const signals = new WeakMap() /** * Get the associated signal of a given controller. */ function getSignal(controller: AbortController): AbortSignal { 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 { AbortController, AbortSignal } mysticatea-abort-controller-66ac7b4/src/abort-signal.ts000066400000000000000000000044261344763160600233220ustar00rootroot00000000000000import { // Event, EventTarget, // Type, defineEventAttribute, } from "event-target-shim" // Known Limitation // Use `any` because the type of `AbortSignal` in `lib.dom.d.ts` is wrong and // to make assignable our `AbortSignal` into that. // https://github.com/Microsoft/TSJS-lib-generator/pull/623 type Events = { abort: any // Event & Type<"abort"> } type EventAttributes = { onabort: any // Event & Type<"abort"> } /** * The signal class. * @see https://dom.spec.whatwg.org/#abortsignal */ export default class AbortSignal extends EventTarget { /** * AbortSignal cannot be constructed directly. */ public constructor() { super() throw new TypeError("AbortSignal cannot be constructed directly") } /** * Returns `true` if this `AbortSignal`'s `AbortController` has signaled to abort, and `false` otherwise. */ public get aborted(): boolean { 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. */ export function createAbortSignal(): AbortSignal { const signal = Object.create(AbortSignal.prototype) EventTarget.call(signal) abortedFlags.set(signal, false) return signal } /** * Abort a given signal. */ export function abortSignal(signal: AbortSignal): void { if (abortedFlags.get(signal) !== false) { return } abortedFlags.set(signal, true) signal.dispatchEvent<"abort">({ 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", }) } mysticatea-abort-controller-66ac7b4/test/000077500000000000000000000000001344763160600205525ustar00rootroot00000000000000mysticatea-abort-controller-66ac7b4/test/fixtures/000077500000000000000000000000001344763160600224235ustar00rootroot00000000000000mysticatea-abort-controller-66ac7b4/test/fixtures/types.ts000066400000000000000000000017371344763160600241470ustar00rootroot00000000000000import { AbortController as AbortControllerShim, AbortSignal as AbortSignalShim, } from "../../src/abort-controller" function signalCallback(as: AbortSignal) {} function signalShimCallback(as: AbortSignalShim) {} function controllerCallback(ac: AbortController) {} function controllerShimCallback(ac: AbortControllerShim) {} function abortCallback(this: AbortSignal, ev: Event) {} const controller = new AbortController() const controllerShim = new AbortControllerShim() const signal = controller.signal const signalShim = controllerShim.signal signalCallback(signal) signalCallback(signalShim) signalShimCallback(signalShim) controllerCallback(controller) controllerCallback(controllerShim) controllerShimCallback(controllerShim) if (signalShim.aborted === false) { signalShim.addEventListener("abort", abortCallback) signalShim.removeEventListener("abort", abortCallback) signalShim.onabort = null signalShim.onabort = abortCallback } controllerShim.abort() mysticatea-abort-controller-66ac7b4/test/index.ts000066400000000000000000000117031344763160600222330ustar00rootroot00000000000000/** * @author Toru Nagashima * See LICENSE file in root directory for full license. */ import assert from "assert" import { AbortController, AbortSignal } from "../src/abort-controller" import { spy } from "@mysticatea/spy" /*globals EventTarget */ const HAS_EVENT_TARGET_INTERFACE = typeof EventTarget !== "undefined" const SUPPORTS_TOSTRINGTAG = typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol" //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ describe("AbortController", () => { let controller: AbortController beforeEach(() => { controller = new AbortController() }) it("should not be callable", () => { assert.throws(() => (AbortController as any)(), TypeError) }) it("should have 2 properties", () => { // IE does not support Set constructor. const keys = new Set() keys.add("signal") keys.add("abort") for (const key in controller) { assert(keys.has(key), `'${key}' found, but should not have it`) keys.delete(key) } keys.forEach(key => { assert(false, `'${key}' not found`) }) }) // ;(SUPPORTS_TOSTRINGTAG ? it : xit)( "should be stringified as [object AbortController]", () => { assert(controller.toString() === "[object AbortController]") }, ) describe("'signal' property", () => { let signal: AbortSignal beforeEach(() => { signal = controller.signal }) it("should return the same instance always", () => { assert(signal === controller.signal) }) it("should be a AbortSignal object", () => { assert(signal instanceof AbortSignal) }) ;(HAS_EVENT_TARGET_INTERFACE ? it : xit)( "should be a EventTarget object", () => { assert(signal instanceof EventTarget) }, ) it("should have 5 properties", () => { // IE does not support Set constructor. const keys = new Set() keys.add("addEventListener") keys.add("removeEventListener") keys.add("dispatchEvent") keys.add("aborted") keys.add("onabort") for (const key in signal) { assert(keys.has(key), `'${key}' found, but should not have it`) keys.delete(key) } keys.forEach(key => { assert(false, `'${key}' not found`) }) }) it("should have 'aborted' property which is false by default", () => { assert(signal.aborted === false) }) it("should have 'onabort' property which is null by default", () => { assert(signal.onabort === null) }) it("should throw a TypeError if 'signal.aborted' getter is called with non AbortSignal object", () => { const getAborted = Object.getOwnPropertyDescriptor( (signal as any).__proto__, "aborted", )!.get assert.throws(() => getAborted!.call({}), TypeError) }) ;(SUPPORTS_TOSTRINGTAG ? it : xit)( "should be stringified as [object AbortSignal]", () => { assert(signal.toString() === "[object AbortSignal]") }, ) }) describe("'abort' method", () => { it("should set true to 'signal.aborted' property", () => { controller.abort() assert(controller.signal.aborted) }) it("should fire 'abort' event on 'signal' (addEventListener)", () => { const listener = spy() controller.signal.addEventListener("abort", listener) controller.abort() assert(listener.calls.length === 1) }) it("should fire 'abort' event on 'signal' (onabort)", () => { const listener = spy() controller.signal.onabort = listener controller.abort() assert(listener.calls.length === 1) }) it("should not fire 'abort' event twice", () => { const listener = spy() controller.signal.addEventListener("abort", listener) controller.abort() controller.abort() controller.abort() assert(listener.calls.length === 1) }) it("should throw a TypeError if 'this' is not an AbortController object", () => { assert.throws(() => controller.abort.call({}), TypeError) }) }) }) describe("AbortSignal", () => { it("should not be callable", () => { assert.throws(() => (AbortSignal as any)(), TypeError) }) it("should throw a TypeError when it's constructed directly", () => { assert.throws(() => new AbortSignal(), TypeError) }) }) mysticatea-abort-controller-66ac7b4/test/polyfill.ts000066400000000000000000000012341344763160600227540ustar00rootroot00000000000000/** * @author Toru Nagashima * See LICENSE file in root directory for full license. */ import assert from "assert" import "../polyfill" const IN_BROWSER = typeof window !== "undefined" || typeof self !== "undefined" // ;(IN_BROWSER ? describe : xdescribe)("abort-controller/polyfill", () => { describe("window.AbortController", () => { it("should not be undefined.", () => { assert(typeof AbortController !== "undefined") }) }) describe("window.AbortSignal", () => { it("should not be undefined.", () => { assert(typeof AbortSignal !== "undefined") }) }) }) mysticatea-abort-controller-66ac7b4/test/types.ts000066400000000000000000000014521344763160600222700ustar00rootroot00000000000000import path from "path" import { TypeTester } from "type-tester" import ts from "typescript" const tester = new TypeTester(ts) describe("TypeScript type definitions", () => { describe("'abort-controller.ts' should have no error even if it was compiled without 'lib.dom.d.ts'.", () => { tester.verify([path.resolve(__dirname, "../src/abort-controller.ts")], { lib: ["lib.es2015.d.ts"], moduleResolution: ts.ModuleResolutionKind.NodeJs, strict: true, target: ts.ScriptTarget.ES2015, }) }) tester.verify([path.resolve(__dirname, "fixtures/types.ts")], { lib: ["lib.es2015.d.ts", "lib.dom.d.ts"], moduleResolution: ts.ModuleResolutionKind.NodeJs, strict: true, target: ts.ScriptTarget.ES2015, }) }) mysticatea-abort-controller-66ac7b4/tsconfig.json000066400000000000000000000011051344763160600222770ustar00rootroot00000000000000{ "compilerOptions": { "allowSyntheticDefaultImports": true, "declaration": true, "esModuleInterop": true, "lib": ["es2015", "dom"], "module": "commonjs", "moduleResolution": "node", "newLine": "LF", "noFallthroughCasesInSwitch": true, "noImplicitReturns": true, "noUnusedLocals": true, "noUnusedParameters": true, "sourceMap": true, "strict": true, "target": "es2015" }, "include": [ "scripts/*.ts", "src/*.ts", "test/*.ts" ] }