{"name":"abortcontroller-polyfill","version":"1.0.8","description":"Browser polyfill for the AbortController DOM API (stub that calls catch, doesn't actually abort request).","main":"dist/browser-polyfill.js","scripts":{"build":"mkdir -p dist ; babel src/ --out-dir dist/ ; cat dist/abortcontroller.js dist/patch-fetch.js > dist/browser-polyfill.js","test":"SELENIUM_BROWSER=chrome E2E_HEADLESS=1 ./scripts/wdio-suppress-exitcode","test-chrome":"SELENIUM_BROWSER=chrome ./scripts/wdio-suppress-exitcode","test-firefox":"SELENIUM_BROWSER=firefox ./scripts/wdio-suppress-exitcode","test-inspect-brk":"E2E_WDIO_EXEC_ARGV=--inspect-brk npm run test-chrome","test-verbose":"SELENIUM_BROWSER=chrome E2E_LOG_LEVEL=verbose wdio wdio.conf.js","eslint":"eslint ."},"babel":{"presets":["latest"]},"keywords":[],"repository":{"type":"git","url":"git+https://github.com/mo/abortcontroller-polyfill.git"},"author":{"name":"Martin Olsson","email":"martin@minimum.se","url":"https://mo.github.io"},"license":"MIT","devDependencies":{"babel-cli":"^6.24.1","babel-preset-latest":"^6.24.1","eslint":"^4.5.0","wdio-jasmine-framework":"^0.3.1","wdio-selenium-standalone-service":"0.0.9","wdio-spec-reporter":"^0.1.0","webdriverio":"^4.8.0"},"gitHead":"c0fe825dd7da9460bc768f4969eaa8eeb5291761","bugs":{"url":"https://github.com/mo/abortcontroller-polyfill/issues"},"homepage":"https://github.com/mo/abortcontroller-polyfill#readme","_id":"abortcontroller-polyfill@1.0.8","_npmVersion":"5.5.1","_nodeVersion":"8.9.0","_npmUser":{"name":"molsson","email":"martin@minimum.se"},"dist":{"integrity":"sha512-nbA1+IoLm2CyC/YOldUCkf9K5ImGYV9z0+cFR5If/PmWWYDV9QVt59tobzo+8W1+e1sTcudky4QNzCkQJc3KGw==","shasum":"bddc3adfe219b4500ee72ff04c6b44a62cced241","tarball":"http://registry-npm.ywwl.com/abortcontroller-polyfill/download/abortcontroller-polyfill-1.0.8.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDiRZL/GdjckwwuXm6DEDrAy+A4ArhoP0EqYj/eaPBTkQIhAPj9eHQiT55ONmHK2CWEoRNPdyHpFTHifiPCYln038Xh"}],"size":6998,"noattachment":false,"key":"/abortcontroller-polyfill/-/abortcontroller-polyfill-1.0.8.tgz"},"maintainers":[{"name":"molsson","email":"martin@minimum.se"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/abortcontroller-polyfill-1.0.8.tgz_1511900931348_0.5554154303390533"},"directories":{},"readme":"# AbortController polyfill for abortable fetch()\n\n[![npm version](https://badge.fury.io/js/abortcontroller-polyfill.svg)](https://badge.fury.io/js/abortcontroller-polyfill)\n\nMinimal stubs so that the AbortController DOM API for terminating ```fetch()``` requests can be used\nin browsers that doesn't yet implement it. This \"polyfill\" doesn't actually close the connection\nwhen the request is aborted, but it will call ```.catch()``` with ```err.name == 'AbortError'```\ninstead of ```.then()```.\n\n```js\nconst controller = new AbortController();\nconst signal = controller.signal;\nfetch('/some/url', {signal})\n  .then(res => res.json())\n  .then(data => {\n    // do something with \"data\"\n  }).catch(err => {\n    if (err.name == 'AbortError') {\n      return;\n    }\n  });\n// controller.abort(); // can be called at any time\n```\n\nYou can read about the [AbortController](https://dom.spec.whatwg.org/#aborting-ongoing-activities) API in the DOM specification.\n\n# How to use\n\n```shell\n$ npm install --save abortcontroller-polyfill\n```\n\nIf you're using webpack or similar, you then import it early in your client entrypoint .js file using\n\n```js\nimport 'abortcontroller-polyfill/dist/polyfill-patch-fetch'\n// or:\nrequire('abortcontroller-polyfill/dist/polyfill-patch-fetch')\n```\n\n## Using it on browsers without fetch\n\nIf you need to support browsers where fetch is not available at all (for example\nInternet Explorer 11), you first need to install a fetch polyfill and then\nimport the ```abortcontroller-polyfill``` afterwards.\n\nThe [unfetch](https://www.npmjs.com/package/unfetch) npm package offers a minimal ```fetch()```\nimplementation (though it does not offer for example a ```Request``` class). If you need a polyfill that\nimplements the full Fetch specification, use the\n[whatwg-fetch](https://www.npmjs.com/package/whatwg-fetch) npm package instead. Typically you will\nalso need to load a polyfill that implements ES6 promises, for example\n[promise-polyfill](https://www.npmjs.com/package/promise-polyfill), and of course you need to avoid\nES6 arrow functions and template literals.\n\nExample projects showing abortable fetch setup so that it works even in Internet Explorer 11, using\nboth unfetch and GitHub fetch, is available\n[here](https://github.com/mo/abortcontroller-polyfill-examples).\n\n## Using it along with 'create-react-app'\n\ncreate-react-app enforces the no-undef eslint rule at compile time so if your\nversion of eslint does not list ```AbortController``` etc as a known global for\nthe ```browser``` environment, then you might run into an compile error like:\n\n```\n  'AbortController' is not defined  no-undef\n```\n\nThis can be worked around by (temporarily, details [here](https://github.com/mo/abortcontroller-polyfill/issues/10)) adding a declaration like:\n\n```js\n  const AbortController = window.AbortController;\n```\n\n## Using the AbortController/AbortSignal without patching fetch\n\nIf you just want to polyfill AbortController/AbortSignal without patching fetch\nyou can use:\n\n```js\nimport 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'\n```\n\n# Using it on Node.js\n\nYou can either import it as a [ponyfill](https://ponyfill.com/) without modifying globals:\n\n```js\nconst { AbortController, abortableFetch } = require('abortcontroller-polyfill/dist/cjs-ponyfill');\nconst { fetch } = abortableFetch(require('node-fetch'));\n// or\n// import { AbortController, abortableFetch } from 'abortcontroller-polyfill/dist/cjs-ponyfill';\n// import _fetch from 'node-fetch';\n// const { fetch } = abortableFetch(_fetch);\n```\nor if you're lazy\n```js\nglobal.fetch = require('node-fetch');\nrequire('abortcontroller-polyfill/dist/polyfill-patch-fetch');\n```\n\nIf you also need a ```Request``` class with support for aborting you can do:\n\n```js\nconst { AbortController, abortableFetch } = require('abortcontroller-polyfill/dist/cjs-ponyfill');\nconst _nodeFetch = require('node-fetch');\nconst { fetch, Request } = abortableFetch({fetch: _nodeFetch, Request: _nodeFetch.Request});\n\nconst controller = new AbortController();\nconst signal = controller.signal;\ncontroller.abort();\nfetch(Request(\"http://api.github.com\", {signal}))\n  .then(r => r.json())\n  .then(j => console.log(j))\n  .catch(err => {\n      if (err.name === 'AbortError') {\n          console.log('aborted');\n      }\n  })\n```\n\nSee also Node.js examples [here](https://github.com/mo/abortcontroller-polyfill-examples/tree/master/node)\n\n# Using it on Internet Explorer 11 (MSIE11)\n\nThe ```abortcontroller-polyfill``` works on Internet Explorer 11. However, to use it you must first\ninstall separate polyfills for promises and for ```fetch()```. For the promise polyfill, you can\nuse the ```promise-polyfill``` package from npm, and for ```fetch()``` you can use either the ```whatwg-fetch``` npm package (complete fetch implementation) or the ```unfetch``` npm package (not a complete polyfill but it's only 500 bytes large and covers a lot of the basic use cases).\n\nIf you choose ```unfetch```, the imports should be done in this order for example:\n\n```js\nimport 'promise-polyfill/src/polyfill';\nimport 'unfetch/polyfill';\nimport 'abortcontroller-polyfill';\n```\n\nSee example code [here](https://github.com/mo/abortcontroller-polyfill-examples/tree/master/create-react-app-msie11).\n\n# Using it on Internet Explorer 8 (MSIE8)\n\nThe ```abortcontroller-polyfill``` works on Internet Explorer 8. However, since ```github-fetch```\nonly supports IE 10+ you need to use the ```fetch-ie8``` npm package instead and also note that IE 8 only\nimplements ES 3 so you need to use the ```es5-shim``` package (or similar). Finally, just like with\nIE 11 you also need to polyfill promises. One caveat is that CORS requests will not work out of the box on IE 8.\n\nHere is a basic example of [abortable fetch running in IE 8](https://github.com/mo/abortcontroller-polyfill-examples/tree/master/plain-javascript-fetch-ie8).\n\n# Contributors\n* [Martin Olsson](https://github.com/mo)\n* [Jimmy Wärting](https://github.com/jimmywarting)\n* [silverwind](https://github.com/silverwind)\n* [Rasmus Jacobsen](https://github.com/rmja)\n* [João Vieira](https://github.com/joaovieira)\n* [Cyril Auburtin](https://github.com/caub)\n* [Leonardo Apiwan](https://github.com/homer0)\n* [Jake Champion](https://github.com/JakeChampion)\n* [Sai Srinivasan](https://github.com/SairamSrinivasan)\n* [Ambar Lee](https://github.com/ambar)\n\n# License\n\nMIT\n","publish_time":1511900932233,"_cnpm_publish_time":1511900932233,"dist-tags":{"latest":"1.7.8"}}