Skip to content
An implementation of WHATWG AbortController interface.
TypeScript JavaScript
Branch: master
Clone or download
Latest commit a935d38 Mar 30, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode 🎨 rewrite with TypeScript Jan 22, 2019
dist 🔖 3.0.0 Mar 30, 2019
scripts
src 🎨 remove an unnecessary if statement Jan 22, 2019
test 🎨 rewrite with TypeScript Jan 22, 2019
.codecov.yml
.eslintignore 🎨 rewrite with TypeScript Jan 22, 2019
.eslintrc.yml 🎨 rewrite with TypeScript Jan 22, 2019
.gitattributes New: abort-controller Oct 2, 2017
.gitignore New: abort-controller Oct 2, 2017
.npmrc New: abort-controller Oct 2, 2017
.nycrc 🎨 rewrite with TypeScript Jan 22, 2019
.travis.yml 🎨 rewrite with TypeScript Jan 22, 2019
LICENSE Initial commit Sep 29, 2017
README.md 📝 update README.md Mar 30, 2019
browser.js 🎨 tweak browser.js/.mjs Mar 30, 2019
browser.mjs 🎨 tweak browser.js/.mjs Mar 30, 2019
karma.conf.js 🎨 rewrite with TypeScript Jan 22, 2019
package.json 🔖 3.0.0 Mar 30, 2019
polyfill.js 🐛 fix polyfill.js/.mjs to work properly Mar 30, 2019
polyfill.mjs 🐛 fix polyfill.js/.mjs to work properly Mar 30, 2019
rollup.config.js 🐛 avoid const in umd build (#13) Mar 7, 2019
tsconfig.json add dts-bundle-generator Jan 22, 2019

README.md

abort-controller

npm version Downloads/month Build Status Coverage Status Dependency Status

An implementation of WHATWG AbortController interface.

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 to install then use a bundler.

npm install abort-controller

Or download from dist directory.

📖 Usage

Basic

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.

import "abort-controller/polyfill"
// or
require("abort-controller/polyfill")

API

AbortController

https://dom.spec.whatwg.org/#interface-abortcontroller

controller.signal

The AbortSignal object which is associated to this controller.

controller.abort()

Notify abort event to listeners that the signal has.

📰 Changelog

🍻 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.
You can’t perform that action at this time.