Comparing version 3.0.0 to 3.1.0
@@ -6,3 +6,3 @@ var index = typeof fetch=='function' ? fetch.bind() : function(url, options) { | ||
request.open(options.method || 'get', url); | ||
request.open(options.method || 'get', url, true); | ||
@@ -29,3 +29,3 @@ for (var i in options.headers) { | ||
request.getAllResponseHeaders().replace(/^(.*?):\s*([\s\S]*?)$/gm, function (m, key, value) { | ||
request.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function (m, key, value) { | ||
keys.push(key = key.toLowerCase()); | ||
@@ -38,3 +38,3 @@ all.push([key, value]); | ||
return { | ||
ok: (request.status/200|0) == 1, // 200-299 | ||
ok: (request.status/100|0) == 2, // 200-299 | ||
status: request.status, | ||
@@ -41,0 +41,0 @@ statusText: request.statusText, |
@@ -1,2 +0,2 @@ | ||
module.exports="function"==typeof fetch?fetch.bind():function(e,t){return t=t||{},new Promise(function(n,r){function s(){var e,t=[],n=[],r={};return o.getAllResponseHeaders().replace(/^(.*?):\s*([\s\S]*?)$/gm,function(s,o,u){t.push(o=o.toLowerCase()),n.push([o,u]),e=r[o],r[o]=e?e+","+u:u}),{ok:1==(o.status/200|0),status:o.status,statusText:o.statusText,url:o.responseURL,clone:s,text:function(){return Promise.resolve(o.responseText)},json:function(){return Promise.resolve(o.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([o.response]))},headers:{keys:function(){return t},entries:function(){return n},get:function(e){return r[e.toLowerCase()]},has:function(e){return e.toLowerCase()in r}}}}var o=new XMLHttpRequest;o.open(t.method||"get",e);for(var u in t.headers)o.setRequestHeader(u,t.headers[u]);o.withCredentials="include"==t.credentials,o.onload=function(){n(s())},o.onerror=r,o.send(t.body)})}; | ||
var e="function"==typeof fetch?fetch.bind():function(e,t){return t=t||{},new Promise(function(n,r){function s(){var e,t=[],n=[],r={};return o.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(s,o,u){t.push(o=o.toLowerCase()),n.push([o,u]),e=r[o],r[o]=e?e+","+u:u}),{ok:2==(o.status/100|0),status:o.status,statusText:o.statusText,url:o.responseURL,clone:s,text:function(){return Promise.resolve(o.responseText)},json:function(){return Promise.resolve(o.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([o.response]))},headers:{keys:function(){return t},entries:function(){return n},get:function(e){return r[e.toLowerCase()]},has:function(e){return e.toLowerCase()in r}}}}var o=new XMLHttpRequest;o.open(t.method||"get",e,!0);for(var u in t.headers)o.setRequestHeader(u,t.headers[u]);o.withCredentials="include"==t.credentials,o.onload=function(){n(s())},o.onerror=r,o.send(t.body)})};module.exports=e; | ||
//# sourceMappingURL=unfetch.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.unfetch=n()}(this,function(){return"function"==typeof fetch?fetch.bind():function(e,n){return n=n||{},new Promise(function(t,o){function r(){var e,n=[],t=[],o={};return s.getAllResponseHeaders().replace(/^(.*?):\s*([\s\S]*?)$/gm,function(r,s,u){n.push(s=s.toLowerCase()),t.push([s,u]),e=o[s],o[s]=e?e+","+u:u}),{ok:1==(s.status/200|0),status:s.status,statusText:s.statusText,url:s.responseURL,clone:r,text:function(){return Promise.resolve(s.responseText)},json:function(){return Promise.resolve(s.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([s.response]))},headers:{keys:function(){return n},entries:function(){return t},get:function(e){return o[e.toLowerCase()]},has:function(e){return e.toLowerCase()in o}}}}var s=new XMLHttpRequest;s.open(n.method||"get",e);for(var u in n.headers)s.setRequestHeader(u,n.headers[u]);s.withCredentials="include"==n.credentials,s.onload=function(){t(r())},s.onerror=o,s.send(n.body)})}}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.unfetch=n()}(this,function(){return"function"==typeof fetch?fetch.bind():function(e,n){return n=n||{},new Promise(function(t,o){function r(){var e,n=[],t=[],o={};return s.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(r,s,u){n.push(s=s.toLowerCase()),t.push([s,u]),e=o[s],o[s]=e?e+","+u:u}),{ok:2==(s.status/100|0),status:s.status,statusText:s.statusText,url:s.responseURL,clone:r,text:function(){return Promise.resolve(s.responseText)},json:function(){return Promise.resolve(s.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([s.response]))},headers:{keys:function(){return n},entries:function(){return t},get:function(e){return o[e.toLowerCase()]},has:function(e){return e.toLowerCase()in o}}}}var s=new XMLHttpRequest;s.open(n.method||"get",e,!0);for(var u in n.headers)s.setRequestHeader(u,n.headers[u]);s.withCredentials="include"==n.credentials,s.onload=function(){t(r())},s.onerror=o,s.send(n.body)})}}); | ||
//# sourceMappingURL=unfetch.umd.js.map |
{ | ||
"name": "unfetch", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "Bare minimum fetch polyfill in 500 bytes", | ||
"unpkg": "dist/unfetch.umd.js", | ||
"main": "dist/unfetch.js", | ||
@@ -13,10 +14,10 @@ "module": "dist/unfetch.es.js", | ||
"clean": "rimraf dist && mkdirp dist", | ||
"rollup:cjs": "cross-env FORMAT=cjs rollup -c rollup.config.js -f cjs -n $npm_package_name -o $npm_package_main", | ||
"rollup:umd": "cross-env FORMAT=umd rollup -c rollup.config.js -f umd -n $npm_package_name -o $npm_package_umd_main", | ||
"rollup:esm": "rollup -c rollup.config.js -f es -n $npm_package_name -o $npm_package_module", | ||
"minify:cjs": "uglifyjs $npm_package_main -cm toplevel -o $npm_package_main -p relative --in-source-map ${npm_package_main}.map --source-map ${npm_package_main}.map", | ||
"minify:umd": "uglifyjs $npm_package_umd_main -cm -o $npm_package_umd_main -p relative --in-source-map ${npm_package_umd_main}.map --source-map ${npm_package_umd_main}.map", | ||
"size": "echo \"Gzipped Size: $(strip-json-comments --no-whitespace $npm_package_main | gzip-size)\"", | ||
"rollup:cjs": "cross-var rollup -c rollup.config.js -f cjs -n unfetch -o $npm_package_main", | ||
"rollup:umd": "cross-var rollup -c rollup.config.js -f umd -n unfetch -o $npm_package_umd_main", | ||
"rollup:esm": "cross-var rollup -c rollup.config.js -f es -n unfetch -o $npm_package_module", | ||
"minify:cjs": "cross-var uglifyjs $npm_package_main -cm toplevel -o $npm_package_main -p relative --in-source-map $npm_package_main.map --source-map $npm_package_main.map", | ||
"minify:umd": "cross-var uglifyjs $npm_package_umd_main -cm -o $npm_package_umd_main -p relative --in-source-map $npm_package_umd_main.map --source-map $npm_package_umd_main.map", | ||
"size": "cross-var echo Gzipped Size: && (cross-var strip-json-comments --no-whitespace $npm_package_main | gzip-size)", | ||
"prepublish": "npm run -s build", | ||
"release": "npm run build -s && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish" | ||
"release": "cross-var npm run build -s && cross-var git commit -am $npm_package_version && cross-var git tag $npm_package_version && git push && git push --tags && npm publish" | ||
}, | ||
@@ -35,2 +36,3 @@ "repository": "developit/unfetch", | ||
"license": "MIT", | ||
"types": "src/index.d.ts", | ||
"files": [ | ||
@@ -61,3 +63,3 @@ "src", | ||
"chai": "^3.5.0", | ||
"cross-env": "^3.1.4", | ||
"cross-var": "^1.1.0", | ||
"eslint": "^3.13.1", | ||
@@ -64,0 +66,0 @@ "gzip-size-cli": "^1.0.0", |
<p align="center"> | ||
<img src="https://i.imgur.com/JaXEFNp.png" width="300" height="300" alt="unfetch"> | ||
<br> | ||
<a href="https://www.npmjs.org/package/unfetch"><img src="https://img.shields.io/npm/v/unfetch.svg?style=flat" alt="npm"></a> <a href="https://travis-ci.org/developit/unfetch"><img src="https://travis-ci.org/developit/unfetch.svg?branch=master" alt="travis"></a> | ||
<a href="https://www.npmjs.org/package/unfetch"><img src="https://img.shields.io/npm/v/unfetch.svg?style=flat" alt="npm"></a> | ||
<a href="https://cdn.jsdelivr.net/npm/unfetch/dist/unfetch.umd.js"><img src="http://img.badgesize.io/https://cdn.jsdelivr.net/npm/unfetch/dist/unfetch.umd.js?compression=gzip" alt="gzip size"></a> | ||
<a href="https://packagephobia.now.sh/result?p=unfetch"><img src="https://packagephobia.now.sh/badge?p=unfetch" alt="install size"></a> | ||
<a href="https://www.npmjs.com/package/unfetch"><img src="https://img.shields.io/npm/dt/unfetch.svg" alt="downloads" ></a> | ||
<a href="https://travis-ci.org/developit/unfetch"><img src="https://travis-ci.org/developit/unfetch.svg?branch=master" alt="travis"></a> | ||
</p> | ||
@@ -22,2 +26,3 @@ | ||
> - No streaming, just Promisifies existing XMLHttpRequest response bodies | ||
> - Use in Node.JS is handled by [isomorphic-unfetch](https://github.com/developit/unfetch/tree/master/packages/isomorphic-unfetch) | ||
@@ -119,3 +124,3 @@ * * * | ||
## API | ||
While one of Unfetch's goals is to provide a familiar interface, it's API may differ from other `fetch` polyfills/ponyfills. | ||
While one of Unfetch's goals is to provide a familiar interface, its API may differ from other `fetch` polyfills/ponyfills. | ||
One of the key differences is that Unfetch focuses on implementing the [`fetch()` API](https://fetch.spec.whatwg.org/#fetch-api), while offering minimal (yet functional) support to the other sections of the [Fetch spec](https://fetch.spec.whatwg.org/), like the [Headers class](https://fetch.spec.whatwg.org/#headers-class) or the [Response class](https://fetch.spec.whatwg.org/#response-class). | ||
@@ -122,0 +127,0 @@ Unfetch's API is organized as follows: |
@@ -6,3 +6,3 @@ export default typeof fetch=='function' ? fetch.bind() : function(url, options) { | ||
request.open(options.method || 'get', url); | ||
request.open(options.method || 'get', url, true); | ||
@@ -29,3 +29,3 @@ for (let i in options.headers) { | ||
request.getAllResponseHeaders().replace(/^(.*?):\s*([\s\S]*?)$/gm, (m, key, value) => { | ||
request.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, (m, key, value) => { | ||
keys.push(key = key.toLowerCase()); | ||
@@ -38,3 +38,3 @@ all.push([key, value]); | ||
return { | ||
ok: (request.status/200|0) == 1, // 200-299 | ||
ok: (request.status/100|0) == 2, // 200-299 | ||
status: request.status, | ||
@@ -41,0 +41,0 @@ statusText: request.statusText, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
28326
12
116
242