httpie
Advanced tools
Comparing version 2.0.0-next.7 to 2.0.0-next.8
@@ -30,4 +30,4 @@ function apply(src, tar) { | ||
return new Promise(function (res, rej) { | ||
fetch(uri, opts).then(function (rr, reply) { | ||
return new Promise((res, rej) => { | ||
fetch(uri, opts).then((rr, reply) => { | ||
clearTimeout(timer); | ||
@@ -42,3 +42,3 @@ | ||
} else { | ||
rr.text().then(function (str) { | ||
rr.text().then(str => { | ||
try { | ||
@@ -53,3 +53,3 @@ rr.data = JSON.parse(str, opts.reviver); | ||
} | ||
}).catch(function (err) { | ||
}).catch(err => { | ||
err.timeout = ctrl && ctrl.signal.aborted; | ||
@@ -56,0 +56,0 @@ rej(err); |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.httpie={})}(this,function(t){function e(t,e){e.headers=t.headers||new Headers,e.statusMessage=t.statusText,e.statusCode=t.status,e.data=t.body}function n(t,n,o){var i,a,s;return(o=o||{}).method=t,o.headers=o.headers||{},o.body&&"object"==typeof o.body&&(o.headers["content-type"]="application/json",o.body=JSON.stringify(o.body)),o.withCredentials&&(o.credentials="include"),o.timeout&&(s=new AbortController,o.signal=s.signal,i=setTimeout(s.abort,o.timeout)),new Promise(function(t,d){fetch(n,o).then(function(n,s){clearTimeout(i),e(n,n),s=n.status>=400?d:t,(a=n.headers.get("content-type"))&&~a.indexOf("application/json")?n.text().then(function(t){try{n.data=JSON.parse(t,o.reviver),s(n)}catch(t){e(n,t),d(t)}}):s(n)}).catch(function(t){t.timeout=s&&s.signal.aborted,d(t)})})}var o=n.bind(n,"GET"),i=n.bind(n,"POST"),a=n.bind(n,"PATCH"),s=n.bind(n,"DELETE"),d=n.bind(n,"PUT");t.del=s,t.get=o,t.patch=a,t.post=i,t.put=d,t.send=n}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.httpie={})}(this,(function(e){function t(e,t){t.headers=e.headers||new Headers,t.statusMessage=e.statusText,t.statusCode=e.status,t.data=e.body}function n(e,n,o){var i,a,s;return(o=o||{}).method=e,o.headers=o.headers||{},o.body&&"object"==typeof o.body&&(o.headers["content-type"]="application/json",o.body=JSON.stringify(o.body)),o.withCredentials&&(o.credentials="include"),o.timeout&&(s=new AbortController,o.signal=s.signal,i=setTimeout(s.abort,o.timeout)),new Promise((e,d)=>{fetch(n,o).then((n,s)=>{clearTimeout(i),t(n,n),s=n.status>=400?d:e,(a=n.headers.get("content-type"))&&~a.indexOf("application/json")?n.text().then(e=>{try{n.data=JSON.parse(e,o.reviver),s(n)}catch(e){t(n,e),d(e)}}):s(n)}).catch(e=>{e.timeout=s&&s.signal.aborted,d(e)})})}var o=n.bind(n,"GET"),i=n.bind(n,"POST"),a=n.bind(n,"PATCH"),s=n.bind(n,"DELETE"),d=n.bind(n,"PUT");e.del=s,e.get=o,e.patch=a,e.post=i,e.put=d,e.send=n})); |
104
httpie.d.ts
@@ -1,27 +0,91 @@ | ||
import { Url, URL } from 'url'; | ||
import { IncomingMessage } from 'http'; | ||
declare module 'httpie' { | ||
import { Url } from 'url'; | ||
export interface HttpieOptions { | ||
body: any; | ||
headers: Record<string, string>; | ||
redirect: boolean; | ||
withCredentials: boolean; | ||
reviver: (key: string, value: any) => any; | ||
timeout: number; | ||
// all options, loose fit | ||
export interface Options { | ||
reviver(key: string, value: any): any; | ||
headers: Headers | Record<string, string>; | ||
withCredentials: boolean; | ||
redirect: boolean; | ||
timeout: number; | ||
body: any; | ||
} | ||
export interface Response<T = any> { | ||
headers: Record<string, string>; | ||
statusMessage: string; | ||
statusCode: number; | ||
data: T; | ||
} | ||
export function send<T = any>(method: string, uri: string | Url | URL, opts?: Partial<Options>): Promise<Response<T>>; | ||
function method<T = any>(uri: string | Url | URL, opts?: Partial<Options>): Promise<Response<T>>; | ||
export { method as get, method as post, method as patch, method as del, method as put }; | ||
} | ||
export interface HttpieResponse<T = any> extends IncomingMessage { | ||
data: T; | ||
declare module 'httpie/node' { | ||
import { Url, URL } from 'url'; | ||
import { IncomingMessage } from 'http'; | ||
export interface Response<T = any> extends IncomingMessage { | ||
data: T; | ||
} | ||
export interface Options { | ||
reviver(key: string, value: any): any; | ||
headers: Record<string, string>; | ||
redirect: boolean; | ||
timeout: number; | ||
body: any; | ||
} | ||
export function send<T = any>(method: string, uri: URL | Url | string, opts?: Partial<Options>): Promise<Response<T>>; | ||
function method<T = any>(uri: URL | Url | string, opts?: Partial<Options>): Promise<Response<T>>; | ||
export { method as get, method as post, method as patch, method as del, method as put }; | ||
} | ||
export declare function send<T = any>(method: string, uri: string | Url | URL, opts?: Partial<HttpieOptions>): Promise<HttpieResponse<T>>; | ||
declare module 'httpie/fetch' { | ||
export interface Response<T = any> extends globalThis.Response { | ||
statusMessage: string; | ||
statusCode: number; | ||
data: T; | ||
} | ||
declare function method<T = any>(uri: string | Url | URL, opts?: Partial<HttpieOptions>): Promise<HttpieResponse<T>>; | ||
export interface Options extends Partial<RequestInit> { | ||
reviver(key: string, value: any): any; | ||
headers: Headers | Record<string, string>; | ||
withCredentials: boolean; | ||
timeout: number; | ||
body: any; | ||
} | ||
export { | ||
method as get, | ||
method as post, | ||
method as patch, | ||
method as del, | ||
method as put, | ||
}; | ||
export function send<T = any>(method: string, uri: URL | string, opts?: Partial<Options>): Promise<Response<T>>; | ||
function method<T = any>(uri: URL | string, opts?: Partial<Options>): Promise<Response<T>>; | ||
export { method as get, method as post, method as patch, method as del, method as put }; | ||
} | ||
declare module 'httpie/xhr' { | ||
export interface Response<T = any> extends XMLHttpRequest { | ||
headers: Record<string, string>; | ||
statusMessage: string; | ||
statusCode: number; | ||
data: T; | ||
} | ||
export interface Options { | ||
reviver(key: string, value: any): any; | ||
headers: Record<string, string>; | ||
withCredentials: boolean; | ||
redirect: boolean; | ||
timeout: number; | ||
body: any; | ||
} | ||
export function send<T = any>(method: string, uri: URL | string, opts?: Partial<Options>): Promise<Response<T>>; | ||
function method<T = any>(uri: URL | string, opts?: Partial<Options>): Promise<Response<T>>; | ||
export { method as get, method as post, method as patch, method as del, method as put }; | ||
} |
{ | ||
"name": "httpie", | ||
"version": "2.0.0-next.7", | ||
"version": "2.0.0-next.8", | ||
"repository": "lukeed/httpie", | ||
"description": "A lightweight, Promise-based wrapper for Node.js HTTP requests~!", | ||
"unpkg": "dist/index.min.js", | ||
"browser": "dist/index.esm.js", | ||
"description": "A lightweight, Promise-based HTTP client for Node.js and the browser~!", | ||
"browser": "xhr/index.mjs", | ||
"unpkg": "xhr/index.min.js", | ||
"worker": "fetch/index.mjs", | ||
"module": "dist/index.mjs", | ||
"main": "dist/index.js", | ||
"module": "node/index.mjs", | ||
"main": "node/index.js", | ||
"types": "httpie.d.ts", | ||
"license": "MIT", | ||
"exports": { | ||
"./": { | ||
"import": "./node/index.mjs", | ||
"require": "./node/index.js", | ||
"browser": "./xhr/index.mjs", | ||
"worker": "./fetch/index.mjs" | ||
}, | ||
"./node": { | ||
"import": "./node/index.mjs", | ||
"require": "./node/index.js" | ||
}, | ||
"./fetch": { | ||
"import": "./fetch/index.mjs", | ||
"require": "./fetch/index.js" | ||
}, | ||
"./browser": { | ||
"import": "./xhr/index.mjs", | ||
"require": "./xhr/index.js" | ||
}, | ||
"./xhr": { | ||
"import": "./xhr/index.mjs", | ||
"require": "./xhr/index.js" | ||
} | ||
}, | ||
"author": { | ||
@@ -22,10 +46,16 @@ "name": "Luke Edwards", | ||
"scripts": { | ||
"build": "node bin", | ||
"pretest": "npm run build", | ||
"test": "tape -r esm test/*.js | tap-spec" | ||
"build": "bundt --main --module --unpkg", | ||
"test": "uvu -r esm test" | ||
}, | ||
"modes": { | ||
"fetch": "src/fetch.js", | ||
"node": "src/node.js", | ||
"xhr": "src/xhr.js" | ||
}, | ||
"files": [ | ||
"*.d.ts", | ||
"fetch", | ||
"dist" | ||
"node", | ||
"xhr" | ||
], | ||
@@ -42,8 +72,6 @@ "keywords": [ | ||
"devDependencies": { | ||
"bundt": "^0.4.0", | ||
"esm": "^3.2.0", | ||
"premove": "1.0.0", | ||
"tap-spec": "^5.0.0", | ||
"tape": "^4.9.1" | ||
"bundt": "1.0.1", | ||
"esm": "3.2.25", | ||
"uvu": "0.0.11" | ||
} | ||
} |
@@ -10,3 +10,3 @@ <div align="center"> | ||
<a href="https://travis-ci.org/lukeed/httpie"> | ||
<img src="https://badgen.now.sh/travis/lukeed/httpie" alt="travis" /> | ||
<img src="https://github.com/lukeed/httpie/workflows/CI/badge.svg" alt="CI" /> | ||
</a> | ||
@@ -21,3 +21,3 @@ <a href="https://codecov.io/gh/lukeed/httpie"> | ||
<div align="center">A Node.js HTTP client as easy as pie!</div> | ||
<div align="center">A Node.js and browser HTTP client as easy as pie!</div> | ||
@@ -24,0 +24,0 @@ ## Features |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
26129
3
13
431
2
10