Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Require Node.js 10 and Ky 0.17
  • Loading branch information
sindresorhus committed Feb 2, 2020
1 parent 1db45f8 commit 2a2a040
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 31 deletions.
1 change: 0 additions & 1 deletion browser.js
@@ -1,2 +1 @@
export {default} from 'ky';
export * from 'ky';
1 change: 0 additions & 1 deletion index.d.ts
@@ -1,2 +1 @@
export {default} from 'ky';
export * from 'ky';
20 changes: 1 addition & 19 deletions index.js
@@ -1,16 +1,7 @@
'use strict';
const {URL, URLSearchParams} = require('url');
const fetch = require('node-fetch');
const AbortController = require('abort-controller');

if (!global.URL) {
global.URL = URL;
}

if (!global.URLSearchParams) {
global.URLSearchParams = URLSearchParams;
}

if (!global.fetch) {
global.fetch = fetch;
}
Expand All @@ -31,13 +22,4 @@ if (!global.AbortController) {
global.AbortController = AbortController;
}

const {
default: ky,
HTTPError,
TimeoutError
} = require('ky/umd');

module.exports = ky;
module.exports.default = ky;
module.exports.HTTPError = HTTPError;
module.exports.TimeoutError = TimeoutError;
module.exports = require('ky/umd');
11 changes: 6 additions & 5 deletions package.json
Expand Up @@ -4,13 +4,14 @@
"description": "Use Ky in both Node.js and browsers",
"license": "MIT",
"repository": "sindresorhus/ky-universal",
"funding": "https://github.com/sindresorhus/ky-universal?sponsor=1",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=8"
"node": ">=10"
},
"scripts": {
"test": "xo && ava"
Expand Down Expand Up @@ -56,12 +57,12 @@
"node-fetch": "^2.6.0"
},
"devDependencies": {
"ava": "^2.2.0",
"ky": "^0.12.0",
"xo": "^0.24.0"
"ava": "^2.4.0",
"ky": "^0.17.0",
"xo": "^0.25.3"
},
"peerDependencies": {
"ky": ">=0.12.0"
"ky": ">=0.17.0"
},
"browser": "browser.js",
"ava": {
Expand Down
5 changes: 0 additions & 5 deletions readme.md
Expand Up @@ -15,7 +15,6 @@ Keep in mind that Ky targets [modern browsers](https://github.com/sindresorhus/k

**If you only target Node.js, I would strongly recommend using [Got](https://github.com/sindresorhus/got) instead.**


## Install

```
Expand All @@ -24,7 +23,6 @@ $ npm install ky ky-universal

*Note that you also need to install `ky`.*


## Usage

```js
Expand All @@ -37,12 +35,10 @@ const ky = require('ky-universal');
})();
```


## API

The API is exactly the same as the [Ky API](https://github.com/sindresorhus/ky#api).


## FAQ

#### How do I use this with a web app (React, Vue.js, etc.) that uses server-side rendering (SSR)?
Expand Down Expand Up @@ -77,7 +73,6 @@ Put the following in package.json:

The library that uses Ky will now *just work* in AVA tests.


## Related

- [ky](https://github.com/sindresorhus/ky) - Tiny and elegant HTTP client based on the browser Fetch API
Expand Down

0 comments on commit 2a2a040

Please sign in to comment.