Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

karl-common-util

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

karl-common-util - npm Package Compare versions

Comparing version 1.3.1 to 1.3.2

183

dist/http/index.js

@@ -28,3 +28,3 @@ "use strict";

promise = new Promise(function _callee(resolve, reject) {
var json, paramArr, k, responese, _responese, status, message;
var json, paramArr, k, v, responese, _responese, status, message;

@@ -49,3 +49,6 @@ return regeneratorRuntime.async(function _callee$(_context) {

for (k in data) {
paramArr.push({ id: k, value: data[k] });
v = data[k];
v = encodeURI(v);
paramArr.push({ id: k, value: v });
}

@@ -151,3 +154,3 @@ if (paramArr.length !== 0) {

var request = function request(_ref2) {
var request = function _callee3(_ref2) {
var url = _ref2.url,

@@ -160,10 +163,75 @@ jwtLocalStorageName = _ref2.jwtLocalStorageName,

method = _ref2.method,
isBrowser = _ref2.isBrowser;
isBrowser = _ref2.isBrowser,
_ref2$times = _ref2.times,
times = _ref2$times === undefined ? 1 : _ref2$times;
var jwt, response;
return regeneratorRuntime.async(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
if (jwtLocalStorageName !== undefined) {
//附加jwt到http header
jwt = localStorage.getItem(jwtLocalStorageName);
if (jwtLocalStorageName !== undefined) {
//附加jwt到http header
var jwt = localStorage.getItem(jwtLocalStorageName);
headers = Object.assign({}, headers, { Authorization: "Bearer " + jwt });
}
return doFetch({ url: url, data: data, method: method, timeout: timeout, headers: headers, contentType: contentType, isBrowser: isBrowser });
headers = Object.assign({}, headers, { Authorization: "Bearer " + jwt });
}
if (!(times > 0)) {
_context3.next = 18;
break;
}
_context3.prev = 2;
_context3.next = 5;
return regeneratorRuntime.awrap(doFetch({
url: url,
data: data,
method: method,
timeout: timeout,
headers: headers,
contentType: contentType,
isBrowser: isBrowser
}));
case 5:
response = _context3.sent;
return _context3.abrupt("return", response);
case 9:
_context3.prev = 9;
_context3.t0 = _context3["catch"](2);
times--;
if (!(times > 0)) {
_context3.next = 17;
break;
}
_context3.next = 15;
return regeneratorRuntime.awrap(request({
url: url,
jwtLocalStorageName: jwtLocalStorageName,
data: data,
timeout: timeout,
headers: headers,
contentType: contentType,
method: method,
isBrowser: isBrowser,
times: times
}));
case 15:
_context3.next = 18;
break;
case 17:
throw _context3.t0;
case 18:
case "end":
return _context3.stop();
}
}
}, null, undefined, [[2, 9]]);
};

@@ -173,21 +241,96 @@

get: function get(jsonParam) {
jsonParam = Object.assign({}, jsonParam, { method: "GET" });
return request(jsonParam);
return regeneratorRuntime.async(function get$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
jsonParam = Object.assign({}, jsonParam, { method: "GET" });
_context4.next = 3;
return regeneratorRuntime.awrap(request(jsonParam));
case 3:
return _context4.abrupt("return", _context4.sent);
case 4:
case "end":
return _context4.stop();
}
}
}, null, undefined);
},
post: function post(jsonParam) {
jsonParam = Object.assign({}, jsonParam, { method: "POST" });
return request(jsonParam);
return regeneratorRuntime.async(function post$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
jsonParam = Object.assign({}, jsonParam, { method: "POST" });
_context5.next = 3;
return regeneratorRuntime.awrap(request(jsonParam));
case 3:
return _context5.abrupt("return", _context5.sent);
case 4:
case "end":
return _context5.stop();
}
}
}, null, undefined);
},
put: function put(jsonParam) {
jsonParam = Object.assign({}, jsonParam, { method: "PUT" });
return request(jsonParam);
return regeneratorRuntime.async(function put$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
jsonParam = Object.assign({}, jsonParam, { method: "PUT" });
_context6.next = 3;
return regeneratorRuntime.awrap(request(jsonParam));
case 3:
return _context6.abrupt("return", _context6.sent);
case 4:
case "end":
return _context6.stop();
}
}
}, null, undefined);
},
patch: function patch(jsonParam) {
jsonParam = Object.assign({}, jsonParam, { method: "PATCH" });
return request(jsonParam);
return regeneratorRuntime.async(function patch$(_context7) {
while (1) {
switch (_context7.prev = _context7.next) {
case 0:
jsonParam = Object.assign({}, jsonParam, { method: "PATCH" });
_context7.next = 3;
return regeneratorRuntime.awrap(request(jsonParam));
case 3:
return _context7.abrupt("return", _context7.sent);
case 4:
case "end":
return _context7.stop();
}
}
}, null, undefined);
},
delete: function _delete(jsonParam) {
jsonParam = Object.assign({}, jsonParam, { method: "DELETE" });
return request(jsonParam);
return regeneratorRuntime.async(function _delete$(_context8) {
while (1) {
switch (_context8.prev = _context8.next) {
case 0:
jsonParam = Object.assign({}, jsonParam, { method: "DELETE" });
_context8.next = 3;
return regeneratorRuntime.awrap(request(jsonParam));
case 3:
return _context8.abrupt("return", _context8.sent);
case 4:
case "end":
return _context8.stop();
}
}
}, null, undefined);
}
};

2

package.json
{
"name": "karl-common-util",
"version": "1.3.1",
"version": "1.3.2",
"description": "karl common lib for client and server",

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

@@ -17,3 +17,5 @@ import "isomorphic-fetch"

for (let k in data) {
paramArr.push({id: k, value: data[k]})
let v = data[k]
v = encodeURI(v)
paramArr.push({id: k, value: v})
}

@@ -20,0 +22,0 @@ if (paramArr.length !== 0) {

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