Comparing version 2.0.0-beta16 to 2.0.0-beta17
@@ -77,2 +77,4 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var xmlHttp = typeof XMLHttpRequest === 'undefined' ? __webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module \"xhr2\""); e.code = 'MODULE_NOT_FOUND'; throw e; }())) : XMLHttpRequest; | ||
// Thanks https://gist.github.com/monsur/706839 | ||
@@ -141,3 +143,3 @@ function headersToJSON(list) { | ||
var address = '' + _this.url + resource; | ||
var request = new XMLHttpRequest(); | ||
var request = new xmlHttp(); | ||
@@ -144,0 +146,0 @@ var handleResponse = function handleResponse() { |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.dtHttp=t():e.dtHttp=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){r(1),e.exports=r(1)},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e){if(!e)return{};var t=function(){var t=e.split("\r\n"),r={};return t.forEach(function(e){var t=e.indexOf(": ");if(t>0){var n=e.substring(0,t),o=e.substring(t+2);r[n.toLowerCase()]=o.toLowerCase()}}),{v:r}}();return"object"==typeof t?t.v:void 0}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(2),u=function(){function e(t){var r=arguments.length<=1||void 0===arguments[1]?Promise:arguments[1];n(this,e),this.httpHeaders=new Map,this.middlewares=new Set,this.url=t,this.promise=r}return a(e,[{key:"setHeader",value:function(e,t){this.httpHeaders.set(e,t)}},{key:"applyMiddleware",value:function(e){this.middlewares.add(e)}},{key:"request",value:function(e,t,r){var n=this,a=arguments.length<=3||void 0===arguments[3]?{}:arguments[3];return new this.promise(function(i,u){var s=""+n.url+t,c=new XMLHttpRequest,f=function(){var e=c.status;c.readyState===c.DONE&&(e>0?!function(){var t=o(c.getAllResponseHeaders()),r=t["content-type"],a=r&&r.indexOf("json")>-1&&c.response.length>0?JSON.parse(c.response):c.response,s={status:e,headers:t,body:a};n.middlewares.size>0?n.middlewares.forEach(function(e){return e({request:c,response:s,resolve:i,reject:u})}):i(s)}():u(Error("request has been failed")))},d=function(e){throw Error(e)};c.withCredentials=a.withCredentials||!1,c.onreadystatechange=f,c.onerror=d,c.open(e,s),n.httpHeaders.forEach(function(e,t){c.setRequestHeader(t,e)}),a.headers&&a.headers.forEach(function(e,t){c.setRequestHeader(t,e)});var l=a.headers?a.headers.get("Content-Type"):n.httpHeaders.get("Content-Type"),p=l&&l.indexOf("json")>-1?JSON.stringify(r):r;c.send(p)})}},{key:"get",value:function(e,t,r){var n=e;if(t){var o=encodeURI(i.JSONToQueryParams(t));n=e+"?"+o}return this.request("GET",n,null,r)}},{key:"post",value:function(e,t,r){return this.request("POST",e,t,r)}},{key:"put",value:function(e,t,r){return this.request("PUT",e,t,r)}},{key:"patch",value:function(e,t,r){return this.request("PATCH",e,t,r)}},{key:"del",value:function(e,t){return this.request("DELETE",e,t)}}]),e}();t["default"]=u,e.exports=t["default"]},function(e,t){"use strict";function r(e,t){return e?Object.keys(e).map(function(n){var o=e[n];return n&&"undefined"!=typeof n&&o&&"undefined"!=typeof o?!(o instanceof Object)||o instanceof Array||o instanceof Function?t?t+"["+n+"]="+o:n+"="+o:r(o,n):null}).filter(function(e){return!!e}).join("&"):void 0}function n(e){return r(e)}function o(e){return JSON.stringify(e)}function a(e){if("string"!=typeof e)return void 0;try{return JSON.parse(e)}catch(t){return e||void 0}}function i(e){return!Object.keys(e).length>0}function u(e,t,r){return e.filter(function(e){return e[t]===r})}function s(e,t,r){return u(e,t,r)[0]}function c(e,t){var r=e.slice();return r.splice(t,1),r}function f(e){var t=arguments.length<=1||void 0===arguments[1]?6e5:arguments[1],r=(new Date).getTime();return r-e>t}function d(e){return parseInt(e.replace(/ /g,"").replace(/-/g,"").replace(/\(/g,"").replace(/\)/g,""),0)}Object.defineProperty(t,"__esModule",{value:!0}),t.JSONToQueryParams=n,t.JSONToString=o,t.stringToJSON=a,t.isObjectEmpty=i,t.findInArray=u,t.getObjectInArray=s,t.popArray=c,t.isOlderThan=f,t.flatPhone=d;var l={string:{capitalize:function(e){return e.charAt(0).toUpperCase()+e.slice(1)}},date:{mask:function(e,t){var r=function(e){return("0"+e).slice(-2)},n=r(e.getDate()),o=r(e.getMonth()+1),a=r(e.getFullYear());return t.replace(/d/g,n).replace(/m/g,o).replace(/y/g,a)}}};t.format=l,t["default"]={JSONToQueryParams:n,JSONToString:o,stringToJSON:a,getObjectInArray:s,isObjectEmpty:i,findInArray:u,popArray:c,isOlderThan:f,flatPhone:d,format:l,isEmpty:i,formatDate:l.date.mask}}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.dtHttp=t():e.dtHttp=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){r(1),e.exports=r(1)},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e){if(!e)return{};var t=function(){var t=e.split("\r\n"),r={};return t.forEach(function(e){var t=e.indexOf(": ");if(t>0){var n=e.substring(0,t),o=e.substring(t+2);r[n.toLowerCase()]=o.toLowerCase()}}),{v:r}}();return"object"==typeof t?t.v:void 0}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),u=r(2),i="undefined"==typeof XMLHttpRequest?r(!function(){var e=new Error('Cannot find module "xhr2"');throw e.code="MODULE_NOT_FOUND",e}()):XMLHttpRequest,s=function(){function e(t){var r=arguments.length<=1||void 0===arguments[1]?Promise:arguments[1];n(this,e),this.httpHeaders=new Map,this.middlewares=new Set,this.url=t,this.promise=r}return a(e,[{key:"setHeader",value:function(e,t){this.httpHeaders.set(e,t)}},{key:"applyMiddleware",value:function(e){this.middlewares.add(e)}},{key:"request",value:function(e,t,r){var n=this,a=arguments.length<=3||void 0===arguments[3]?{}:arguments[3];return new this.promise(function(u,s){var f=""+n.url+t,c=new i,d=function(){var e=c.status;c.readyState===c.DONE&&(e>0?!function(){var t=o(c.getAllResponseHeaders()),r=t["content-type"],a=r&&r.indexOf("json")>-1&&c.response.length>0?JSON.parse(c.response):c.response,i={status:e,headers:t,body:a};n.middlewares.size>0?n.middlewares.forEach(function(e){return e({request:c,response:i,resolve:u,reject:s})}):u(i)}():s(Error("request has been failed")))},l=function(e){throw Error(e)};c.withCredentials=a.withCredentials||!1,c.onreadystatechange=d,c.onerror=l,c.open(e,f),n.httpHeaders.forEach(function(e,t){c.setRequestHeader(t,e)}),a.headers&&a.headers.forEach(function(e,t){c.setRequestHeader(t,e)});var p=a.headers?a.headers.get("Content-Type"):n.httpHeaders.get("Content-Type"),h=p&&p.indexOf("json")>-1?JSON.stringify(r):r;c.send(h)})}},{key:"get",value:function(e,t,r){var n=e;if(t){var o=encodeURI(u.JSONToQueryParams(t));n=e+"?"+o}return this.request("GET",n,null,r)}},{key:"post",value:function(e,t,r){return this.request("POST",e,t,r)}},{key:"put",value:function(e,t,r){return this.request("PUT",e,t,r)}},{key:"patch",value:function(e,t,r){return this.request("PATCH",e,t,r)}},{key:"del",value:function(e,t){return this.request("DELETE",e,t)}}]),e}();t["default"]=s,e.exports=t["default"]},function(e,t){"use strict";function r(e,t){return e?Object.keys(e).map(function(n){var o=e[n];return n&&"undefined"!=typeof n&&o&&"undefined"!=typeof o?!(o instanceof Object)||o instanceof Array||o instanceof Function?t?t+"["+n+"]="+o:n+"="+o:r(o,n):null}).filter(function(e){return!!e}).join("&"):void 0}function n(e){return r(e)}function o(e){return JSON.stringify(e)}function a(e){if("string"!=typeof e)return void 0;try{return JSON.parse(e)}catch(t){return e||void 0}}function u(e){return!Object.keys(e).length>0}function i(e,t,r){return e.filter(function(e){return e[t]===r})}function s(e,t,r){return i(e,t,r)[0]}function f(e,t){var r=e.slice();return r.splice(t,1),r}function c(e){var t=arguments.length<=1||void 0===arguments[1]?6e5:arguments[1],r=(new Date).getTime();return r-e>t}function d(e){return parseInt(e.replace(/ /g,"").replace(/-/g,"").replace(/\(/g,"").replace(/\)/g,""),0)}Object.defineProperty(t,"__esModule",{value:!0}),t.JSONToQueryParams=n,t.JSONToString=o,t.stringToJSON=a,t.isObjectEmpty=u,t.findInArray=i,t.getObjectInArray=s,t.popArray=f,t.isOlderThan=c,t.flatPhone=d;var l={string:{capitalize:function(e){return e.charAt(0).toUpperCase()+e.slice(1)}},date:{mask:function(e,t){var r=function(e){return("0"+e).slice(-2)},n=r(e.getDate()),o=r(e.getMonth()+1),a=r(e.getFullYear());return t.replace(/d/g,n).replace(/m/g,o).replace(/y/g,a)}}};t.format=l,t["default"]={JSONToQueryParams:n,JSONToString:o,stringToJSON:a,getObjectInArray:s,isObjectEmpty:u,findInArray:i,popArray:f,isOlderThan:c,flatPhone:d,format:l,isEmpty:u,formatDate:l.date.mask}}])}); |
@@ -13,2 +13,4 @@ 'use strict'; | ||
var xmlHttp = typeof XMLHttpRequest === 'undefined' ? require('xhr2') : XMLHttpRequest; | ||
// Thanks https://gist.github.com/monsur/706839 | ||
@@ -77,3 +79,3 @@ function headersToJSON(list) { | ||
var address = '' + _this.url + resource; | ||
var request = new XMLHttpRequest(); | ||
var request = new xmlHttp(); | ||
@@ -80,0 +82,0 @@ var handleResponse = function handleResponse() { |
{ | ||
"name": "dthttp", | ||
"version": "2.0.0-beta16", | ||
"version": "2.0.0-beta17", | ||
"description": "Simple class-based HTTP client with Promises", | ||
"main": "lib/index.js", | ||
"files": [ | ||
"dist", | ||
"lib", | ||
"src" | ||
], | ||
"scripts": { | ||
@@ -33,3 +38,4 @@ "lint": "eslint src", | ||
"dependencies": { | ||
"@dtrussia/utils.js": "1.0.0" | ||
"@dtrussia/utils.js": "1.0.0", | ||
"xhr2": "^0.1.3" | ||
}, | ||
@@ -39,3 +45,3 @@ "devDependencies": { | ||
"babel-core": "5.8.30", | ||
"babel-eslint": "4.1.3", | ||
"babel-eslint": "4.1.7", | ||
"babel-loader": "5.3.2", | ||
@@ -42,0 +48,0 @@ "eslint": "1.7.3", |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
27037
542
2
6
1
+ Addedxhr2@^0.1.3
+ Addedxhr2@0.1.4(transitive)