Comparing version 3.2.4 to 3.3.0
@@ -1,1 +0,1 @@ | ||
'use strict';const{URL}=require('url'),centra=require('centra'),phin=async a=>{if('string'!=typeof a&&!a.hasOwnProperty('url'))throw new Error('Missing url option from options for request method.');const b=centra('object'==typeof a?a.url:a,a.method||'GET');a.headers&&b.header(a.headers),a.stream&&b.stream(),a.timeout&&b.timeout(a.timeout),a.data&&b.body(a.data),a.form&&b.body(a.form,'form'),a.compression&&b.compress();const c=await b.send();return c.headers.hasOwnProperty('location')&&a.followRedirects?(a.url=new URL(c.headers.location,a.url).toString(),await phin(a)):a.stream?(c.stream=c,c):(c.coreRes.body=c.body,a.parse&&'json'===a.parse?(c.coreRes.body=await c.json(),c.coreRes):c.coreRes)};phin.promisified=phin,phin.unpromisified=(a,b)=>{phin(a).then(c=>{b&&b(null,c)}).catch(c=>{b&&b(c,null)})},phin.defaults=a=>async b=>await phin(Object.assign(a,'string'==typeof b?{url:b}:b)),module.exports=phin; | ||
'use strict';var _typeof='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&'function'==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?'symbol':typeof a},_require=require('url'),URL=_require.URL,centra=require('centra'),phin=async function(a){if('string'!=typeof a&&!a.hasOwnProperty('url'))throw new Error('Missing url option from options for request method.');var b=centra('object'===('undefined'==typeof a?'undefined':_typeof(a))?a.url:a,a.method||'GET');a.headers&&b.header(a.headers),a.stream&&b.stream(),a.timeout&&b.timeout(a.timeout),a.data&&b.body(a.data),a.form&&b.body(a.form,'form'),a.compression&&b.compress(),'object'===_typeof(a.core)&&Object.keys(a.core).forEach(function(d){b.option(d,a.core[d])});var c=await b.send();return c.headers.hasOwnProperty('location')&&a.followRedirects?(a.url=new URL(c.headers.location,a.url).toString(),await phin(a)):a.stream?(c.stream=c,c):(c.coreRes.body=c.body,a.parse&&'json'===a.parse?(c.coreRes.body=await c.json(),c.coreRes):c.coreRes)};phin.promisified=phin,phin.unpromisified=function(a,b){phin(a).then(function(c){b&&b(null,c)}).catch(function(c){b&&b(c,null)})},phin.defaults=function(a){return async function(b){return await phin(Object.assign(a,'string'==typeof b?{url:b}:b))}},module.exports=phin; |
{ | ||
"name": "phin", | ||
"version": "3.2.4", | ||
"version": "3.3.0", | ||
"description": "The ultra-lightweight Node.js HTTP client", | ||
@@ -29,3 +29,3 @@ "main": "lib/phin.min.js", | ||
}, | ||
"homepage": "https://github.com/ethanent/phin#readme", | ||
"homepage": "https://github.com/ethanent/phin", | ||
"devDependencies": { | ||
@@ -32,0 +32,0 @@ "jsdoc": "^3.5.5", |
@@ -22,2 +22,3 @@ <p align="center" style="text-align: center"><img src="https://raw.githubusercontent.com/ethanent/phin/master/media/phin-textIncluded.png" width="250" alt="phin logo"/></p> | ||
## Install | ||
@@ -53,3 +54,3 @@ | ||
## Unpromisified Usage | ||
### Unpromisified Usage | ||
@@ -70,4 +71,4 @@ ```js | ||
const res = await p({ | ||
url: 'https://ethanent.me/name', | ||
parse: 'json' | ||
'url': 'https://ethanent.me/name', | ||
'parse': 'json' | ||
}) | ||
@@ -78,3 +79,3 @@ | ||
## Default options | ||
### Default Options | ||
@@ -96,7 +97,23 @@ ```js | ||
### Custom Core HTTP Options | ||
phin allows you to set [core HTTP options](https://nodejs.org/api/http.html#http_http_request_url_options_callback). | ||
```js | ||
await p({ | ||
'url': 'https://ethanent.me/name', | ||
'core': { | ||
'agent': myAgent // Assuming you'd already created myAgent earlier. | ||
} | ||
}) | ||
``` | ||
## Full Documentation | ||
There's a lot more which can be done with the phin library. | ||
See [the phin documentation](https://ethanent.github.io/phin/). | ||
## phin vs. the Competition | ||
@@ -113,2 +130,3 @@ | ||
isomorphic-fetch | [![isomorphic-fetch package size](https://packagephobia.now.sh/badge?p=isomorphic-fetch)](https://packagephobia.now.sh/result?p=isomorphic-fetch) | ||
axios | [![axios package size](https://packagephobia.now.sh/badge?p=axios)](https://packagephobia.now.sh/result?p=axios) | ||
got | [![got package size](https://packagephobia.now.sh/badge?p=got)](https://packagephobia.now.sh/result?p=got) | ||
@@ -115,0 +133,0 @@ r2 | [![r2 package size](https://packagephobia.now.sh/badge?p=r2)](https://packagephobia.now.sh/result?p=r2) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7264
130