New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dthttp

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dthttp - npm Package Compare versions

Comparing version 2.0.0-beta15 to 2.0.0-beta16

2

dist/index.js

@@ -150,3 +150,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

var contentType = headers['content-type'];
var body = contentType && contentType.indexOf('json') > -1 ? JSON.parse(request.response) : request.response;
var body = contentType && contentType.indexOf('json') > -1 && request.response.length > 0 ? JSON.parse(request.response) : request.response;

@@ -153,0 +153,0 @@ var response = { status: status, headers: headers, body: body };

@@ -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?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}}(),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}}])});

@@ -86,3 +86,3 @@ 'use strict';

var contentType = headers['content-type'];
var body = contentType && contentType.indexOf('json') > -1 ? JSON.parse(request.response) : request.response;
var body = contentType && contentType.indexOf('json') > -1 && request.response.length > 0 ? JSON.parse(request.response) : request.response;

@@ -89,0 +89,0 @@ var response = { status: status, headers: headers, body: body };

{
"name": "dthttp",
"version": "2.0.0-beta15",
"version": "2.0.0-beta16",
"description": "Simple class-based HTTP client with Promises",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc