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

http-client

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-client - npm Package Compare versions

Comparing version 4.2.0 to 4.3.0

9

CHANGES.md

@@ -0,1 +1,10 @@

## [v4.3.0]
> Sep 30, 2016
- Rename `onResponse` to `recv` and `enhanceFetch` to `enableRecv`. This makes the association more clear.
- Deprecated redundant top-level `fetch` export. Use the global `fetch` function directly instead.
- Added `debug` middleware, deprecated `requestInfo`.
[v4.3.0]: https://github.com/mjackson/http-client/compare/v4.2.0...v4.3.0
## [v4.2.0]

@@ -2,0 +11,0 @@ > Sep 29, 2016

50

index.js

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

});
exports.requestInfo = exports.parseText = exports.parseJSON = exports.parse = exports.handleResponse = exports.onResponse = exports.params = exports.json = exports.body = exports.query = exports.base = exports.accept = exports.auth = exports.header = exports.method = exports.init = exports.createFetch = exports.createStack = exports.fetch = exports.enhanceFetch = undefined;
exports.requestInfo = exports.debug = exports.parseText = exports.parseJSON = exports.parse = exports.onResponse = exports.handleResponse = exports.recv = exports.params = exports.json = exports.body = exports.query = exports.base = exports.accept = exports.auth = exports.header = exports.method = exports.init = exports.fetch = exports.createFetch = exports.createStack = exports.enhanceFetch = exports.enableRecv = undefined;

@@ -27,3 +27,3 @@ var _queryString = require('query-string');

var enhanceResponse = function enhanceResponse(response, handlers) {
var processResponse = function processResponse(response, handlers) {
return handlers.reduce(function (promise, handler) {

@@ -38,3 +38,3 @@ return promise.then(handler);

*/
var enhanceFetch = exports.enhanceFetch = function enhanceFetch(fetch) {
var enableRecv = exports.enableRecv = function enableRecv(fetch) {
return function (input) {

@@ -45,3 +45,3 @@ var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

return responseHandlers && responseHandlers.length ? enhanceResponse(response, responseHandlers) : response;
return responseHandlers && responseHandlers.length ? processResponse(response, responseHandlers) : response;
});

@@ -51,7 +51,5 @@ };

var enhancedGlobalFetch = enhanceFetch(global.fetch);
// Deprecated.
var enhanceFetch = exports.enhanceFetch = enableRecv;
exports.fetch = enhancedGlobalFetch;
var emptyStack = function emptyStack(fetch, input, options) {

@@ -99,7 +97,7 @@ return fetch(input, options);

var createFetch = exports.createFetch = function createFetch() {
if (arguments.length === 0) return enhancedGlobalFetch;
if (arguments.length === 0) return global.fetch;
var stack = createStack.apply(undefined, arguments);
return enhanceFetch(function (input) {
return enableRecv(function (input) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

@@ -110,5 +108,10 @@ return stack(global.fetch, input, options);

// Deprecated.
var mainFetch = enableRecv(global.fetch);
exports.fetch = mainFetch;
/**
* Sets a property name and value in the options object.
*/
var init = exports.init = function init(propertyName, value) {

@@ -224,3 +227,3 @@ return function (fetch, input) {

*/
var onResponse = exports.onResponse = function onResponse(handler) {
var recv = exports.recv = function recv(handler) {
return function (fetch, input) {

@@ -235,3 +238,4 @@ var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];

// Deprecated.
var handleResponse = exports.handleResponse = onResponse;
var handleResponse = exports.handleResponse = recv;
var onResponse = exports.onResponse = recv;

@@ -244,3 +248,3 @@ /**

var as = arguments.length <= 1 || arguments[1] === undefined ? 'body' : arguments[1];
return onResponse(function (response) {
return recv(function (response) {
if (as in response) return response[as];

@@ -270,5 +274,21 @@

/**
* Adds the requestURL and requestOptions properties to the
* response/error. Mainly useful in testing/debugging.
* Adds a debug property to the response/error that contains
* the input and options used in the request. Mainly useful in
* testing and debugging.
*/
var debug = exports.debug = function debug() {
return function (fetch, input, options) {
return fetch(input, options).then(function (response) {
response.debug = { input: input, options: options };
return response;
}, function () {
var error = arguments.length <= 0 || arguments[0] === undefined ? new Error() : arguments[0];
error.debug = { input: input, options: options };
throw error;
});
};
};
// Deprecated.
var requestInfo = exports.requestInfo = function requestInfo() {

@@ -275,0 +295,0 @@ return function (fetch, input, options) {

{
"name": "http-client",
"version": "4.2.0",
"version": "4.3.0",
"description": "Compose HTTP clients using JavaScript's fetch API",

@@ -5,0 +5,0 @@ "repository": "mjackson/http-client",

@@ -47,3 +47,3 @@ # http-client [![Travis][build-badge]][build] [![npm package][npm-badge]][npm]

```js
import { createFetch, base, accept, parseJSON } from 'http-client'
import { createFetch, base, accept, parse } from 'http-client'

@@ -53,3 +53,3 @@ const fetch = createFetch(

accept('application/json'), // Set "Accept: application/json" in the request headers
parseJSON() // Read the response as JSON and put it in response.jsonData
parse('json') // Read the response as JSON and put it in response.body
)

@@ -62,4 +62,2 @@

http-client also exports a base `fetch` function if you need it (i.e. don't want middleware).
## Top-level API

@@ -69,20 +67,12 @@

Creates an [enhanced](#enhancefetchfetch) `fetch` function that is fronted by some middleware.
Creates a `fetch` function that uses some [middleware](#middleware). Uses the global `fetch` function to actually make the request.
#### `createStack(...middleware)`
Combines several middleware into one, in the same order they are provided as arguments. Use this function to create re-usable [middleware stacks](#stacks).
Combines several middleware into one, in the same order they are provided as arguments. Use this function to create re-usable [middleware stacks](#stacks) or if you don't want to use a global `fetch` function.
#### `enhanceFetch(fetch)`
#### `enableRecv(fetch)`
Returns an "enhanced" version of the given `fetch` function that uses an array of transforms in `options.responseHandlers` to modify the response after it is received.
Returns an "enhanced" version of the given `fetch` function that uses an array of transforms in `options.responseHandlers` to modify the response after it is received. This is only really useful when using [stacks](#stacks) directly instead of the global `fetch` function.
#### `fetch([input], [options])`
An [enhanced](#enhancefetchfetch) `fetch` function. Use this directly if you don't need any middleware.
#### `onResponse(handler)`
A helper for creating middleware that enhances the `response` object in some way. The `handler` function should return the new response value, or a promise for it. Response handlers run in the order they are defined.
## Middleware

@@ -203,3 +193,3 @@

Reads the response body as JSON and puts it on `response.body` (or whatever `as` is). `parser` must be the name of a valid [Body](https://developer.mozilla.org/en-US/docs/Web/API/Body) parsing method. The following parsers are available in [the spec](https://fetch.spec.whatwg.org/#body-mixin):
Reads the response body to completion, parses the response, and puts the result on `response.body` (or whatever `as` is). `parser` must be the name of a valid [Body](https://developer.mozilla.org/en-US/docs/Web/API/Body) parsing method. The following parsers are available in [the spec](https://fetch.spec.whatwg.org/#body-mixin):

@@ -230,2 +220,15 @@ - `arrayBuffer`

#### `recv(handler)`
Used to handle the `response` in some way. The `handler` function should return the new response value, or a promise for it. Response handlers run in the order they are defined.
```js
import { createFetch, recv } from 'http-client'
const fetch = createFetch(
recv(response => (console.log('runs first'), response)),
recv(response => (console.log('runs second'), response))
)
```
#### `requestInfo()`

@@ -250,3 +253,3 @@

Middleware may be combined together into re-usable middleware "stacks" using `createStack`. A stack is itself a middleware that is composed of one or more other pieces of middleware.
Middleware may be combined together into re-usable middleware "stacks" using `createStack`. A stack is itself a middleware that is composed of one or more other pieces of middleware. Thus, you can pass a stack directly to `createFetch` as if it were any other piece of middleware.

@@ -256,3 +259,3 @@ This is useful when you have a common set of functionality that you'd like to share between several different `fetch` methods, e.g.:

```js
import { createStack, createFetch, header, base, parseJSON } from 'http-client'
import { createFetch, createStack, header, base, parse, query } from 'http-client'

@@ -263,3 +266,3 @@ const commonStack = createStack(

base('https://api.cloudflare.com/client/v4'),
parseJSON()
parse('json')
)

@@ -280,10 +283,10 @@

```js
const { enhanceFetch, createStack, header, base } = require('http-client')
const { createStack, enableRecv, header, base } = require('http-client')
// We need to "enhance" node-fetch so it knows how to
// handle responses correctly. Specifically, enhanceFetch
// handle responses correctly. Specifically, enableRecv
// gives a fetch function the ability to run response
// handlers registered with onResponse (which parseJSON,
// used below, uses behind the scenes).
const fetch = enhanceFetch(
// handlers registered with recv (which parse, used below,
// uses behind the scenes).
const fetch = enableRecv(
require('node-fetch')

@@ -296,3 +299,3 @@ )

base('https://api.cloudflare.com/client/v4'),
parseJSON()
parse('json')
)

@@ -299,0 +302,0 @@

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

});
exports.requestInfo = exports.parseText = exports.parseJSON = exports.parse = exports.handleResponse = exports.onResponse = exports.params = exports.json = exports.body = exports.query = exports.base = exports.accept = exports.auth = exports.header = exports.method = exports.init = exports.createFetch = exports.createStack = exports.fetch = exports.enhanceFetch = undefined;
exports.requestInfo = exports.debug = exports.parseText = exports.parseJSON = exports.parse = exports.onResponse = exports.handleResponse = exports.recv = exports.params = exports.json = exports.body = exports.query = exports.base = exports.accept = exports.auth = exports.header = exports.method = exports.init = exports.fetch = exports.createFetch = exports.createStack = exports.enhanceFetch = exports.enableRecv = undefined;

@@ -83,3 +83,3 @@ var _queryString = __webpack_require__(1);

var enhanceResponse = function enhanceResponse(response, handlers) {
var processResponse = function processResponse(response, handlers) {
return handlers.reduce(function (promise, handler) {

@@ -94,3 +94,3 @@ return promise.then(handler);

*/
var enhanceFetch = exports.enhanceFetch = function enhanceFetch(fetch) {
var enableRecv = exports.enableRecv = function enableRecv(fetch) {
return function (input) {

@@ -101,3 +101,3 @@ var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

return responseHandlers && responseHandlers.length ? enhanceResponse(response, responseHandlers) : response;
return responseHandlers && responseHandlers.length ? processResponse(response, responseHandlers) : response;
});

@@ -107,7 +107,5 @@ };

var enhancedGlobalFetch = enhanceFetch(global.fetch);
// Deprecated.
var enhanceFetch = exports.enhanceFetch = enableRecv;
exports.fetch = enhancedGlobalFetch;
var emptyStack = function emptyStack(fetch, input, options) {

@@ -155,7 +153,7 @@ return fetch(input, options);

var createFetch = exports.createFetch = function createFetch() {
if (arguments.length === 0) return enhancedGlobalFetch;
if (arguments.length === 0) return global.fetch;
var stack = createStack.apply(undefined, arguments);
return enhanceFetch(function (input) {
return enableRecv(function (input) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

@@ -166,5 +164,10 @@ return stack(global.fetch, input, options);

// Deprecated.
var mainFetch = enableRecv(global.fetch);
exports.fetch = mainFetch;
/**
* Sets a property name and value in the options object.
*/
var init = exports.init = function init(propertyName, value) {

@@ -280,3 +283,3 @@ return function (fetch, input) {

*/
var onResponse = exports.onResponse = function onResponse(handler) {
var recv = exports.recv = function recv(handler) {
return function (fetch, input) {

@@ -291,3 +294,4 @@ var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];

// Deprecated.
var handleResponse = exports.handleResponse = onResponse;
var handleResponse = exports.handleResponse = recv;
var onResponse = exports.onResponse = recv;

@@ -300,3 +304,3 @@ /**

var as = arguments.length <= 1 || arguments[1] === undefined ? 'body' : arguments[1];
return onResponse(function (response) {
return recv(function (response) {
if (as in response) return response[as];

@@ -326,5 +330,21 @@

/**
* Adds the requestURL and requestOptions properties to the
* response/error. Mainly useful in testing/debugging.
* Adds a debug property to the response/error that contains
* the input and options used in the request. Mainly useful in
* testing and debugging.
*/
var debug = exports.debug = function debug() {
return function (fetch, input, options) {
return fetch(input, options).then(function (response) {
response.debug = { input: input, options: options };
return response;
}, function () {
var error = arguments.length <= 0 || arguments[0] === undefined ? new Error() : arguments[0];
error.debug = { input: input, options: options };
throw error;
});
};
};
// Deprecated.
var requestInfo = exports.requestInfo = function requestInfo() {

@@ -331,0 +351,0 @@ return function (fetch, input, options) {

@@ -1,1 +0,1 @@

!function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.HTTPClient=t():n.HTTPClient=t()}(this,function(){return function(n){function t(r){if(e[r])return e[r].exports;var o=e[r]={exports:{},id:r,loaded:!1};return n[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var e={};return t.m=n,t.c=e,t.p="",t(0)}([function(n,t,e){"use strict";function r(n){return n&&n.__esModule?n:{"default":n}}Object.defineProperty(t,"__esModule",{value:!0}),t.requestInfo=t.parseText=t.parseJSON=t.parse=t.handleResponse=t.onResponse=t.params=t.json=t.body=t.query=t.base=t.accept=t.auth=t.header=t.method=t.init=t.createFetch=t.createStack=t.fetch=t.enhanceFetch=void 0;var o=e(3),u=e(1),i=r(u),c=(0,eval)("this"),a=function(n){return"string"==typeof n?n:(0,o.stringify)(n)},f=function(n){return"string"==typeof n?n:JSON.stringify(n)},s=function(n,t){return t.reduce(function(n,t){return n.then(t)},Promise.resolve(n))},p=t.enhanceFetch=function(n){return function(t){var e=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return n(t,e).then(function(n){var t=e.responseHandlers;return t&&t.length?s(n,t):n})}},l=p(c.fetch);t.fetch=l;var d=function(n,t,e){return n(t,e)},h=t.createStack=function(){for(var n=arguments.length,t=Array(n),e=0;e<n;e++)t[e]=arguments[e];return 0===t.length?d:t.reduceRight(function(n,t){return function(e,r,o){return t(function(t,r){return n(e,t,r)},r,o)}})},v=(t.createFetch=function(){if(0===arguments.length)return l;var n=h.apply(void 0,arguments);return p(function(t){var e=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return n(c.fetch,t,e)})},t.init=function(n,t){return function(e,r){var o=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return o[n]=t,e(r,o)}}),g=(t.method=function(n){return v("method",n)},function(n,t,e){(n.headers||(n.headers={}))[t]=e}),y=t.header=function(n,t){return function(e,r){var o=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return g(o,n,t),e(r,o)}},b=(t.auth=function(n){return y("Authorization",n)},t.accept=function(n){return y("Accept",n)},t.base=function(n){return function(t,e,r){return t(n+(e||""),r)}},t.query=function(n){var t=a(n);return function(n,e,r){return n(e+(e.indexOf("?")===-1?"?":"&")+t,r)}}),j=t.body=function(n,t){return function(e,r){var o=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return o.body=n,null!=n.length&&g(o,"Content-Length",(0,i["default"])(n)),t&&g(o,"Content-Type",t),e(r,o)}},m=(t.json=function(n){return j(f(n),"application/json")},t.params=function(n){var t=a(n);return function(n,e){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],o=(r.method||"GET").toUpperCase(),u="GET"===o||"HEAD"===o?b(t):j(t,"application/x-www-form-urlencoded");return u(n,e,r)}},t.onResponse=function(n){return function(t,e){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return(r.responseHandlers||(r.responseHandlers=[])).push(n),t(e,r)}}),O=(t.handleResponse=m,t.parse=function(n){var t=arguments.length<=1||void 0===arguments[1]?"body":arguments[1];return m(function(e){return t in e?e[t]:e[n]().then(function(n){return e[t]=n,e},function(t){throw new Error("parse('"+n+"') error: "+t.stack)})})});t.parseJSON=function(){var n=arguments.length<=0||void 0===arguments[0]?"jsonData":arguments[0];return O("json",n)},t.parseText=function(){var n=arguments.length<=0||void 0===arguments[0]?"textString":arguments[0];return O("text",n)},t.requestInfo=function(){return function(n,t,e){return n(t,e).then(function(n){return n.requestInput=t,n.requestOptions=e,n},function(){var n=arguments.length<=0||void 0===arguments[0]?new Error:arguments[0];throw n.requestInput=t,n.requestOptions=e,n})}}},function(n,t){"use strict";n.exports=function(n){var t,e;if(!n)return 0;for(n=n.toString(),t=e=n.length;t--;){var r=n[t].charCodeAt();56320<=r&&r<=57343&&t--,127<r&&r<=2047?e++:2047<r&&r<=65535&&(e+=2)}return e}},function(n,t){"use strict";function e(n){if(null===n||void 0===n)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(n)}function r(){try{if(!Object.assign)return!1;var n=new String("abc");if(n[5]="de","5"===Object.getOwnPropertyNames(n)[0])return!1;for(var t={},e=0;e<10;e++)t["_"+String.fromCharCode(e)]=e;var r=Object.getOwnPropertyNames(t).map(function(n){return t[n]});if("0123456789"!==r.join(""))return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(n){o[n]=n}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(u){return!1}}var o=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable;n.exports=r()?Object.assign:function(n,t){for(var r,i,c=e(n),a=1;a<arguments.length;a++){r=Object(arguments[a]);for(var f in r)o.call(r,f)&&(c[f]=r[f]);if(Object.getOwnPropertySymbols){i=Object.getOwnPropertySymbols(r);for(var s=0;s<i.length;s++)u.call(r,i[s])&&(c[i[s]]=r[i[s]])}}return c}},function(n,t,e){"use strict";function r(n,t){return t.encode?t.strict?o(n):encodeURIComponent(n):n}var o=e(4),u=e(2);t.extract=function(n){return n.split("?")[1]||""},t.parse=function(n){var t=Object.create(null);return"string"!=typeof n?t:(n=n.trim().replace(/^(\?|#|&)/,""))?(n.split("&").forEach(function(n){var e=n.replace(/\+/g," ").split("="),r=e.shift(),o=e.length>0?e.join("="):void 0;r=decodeURIComponent(r),o=void 0===o?null:decodeURIComponent(o),void 0===t[r]?t[r]=o:Array.isArray(t[r])?t[r].push(o):t[r]=[t[r],o]}),t):t},t.stringify=function(n,t){var e={encode:!0,strict:!0};return t=u(e,t),n?Object.keys(n).sort().map(function(e){var o=n[e];if(void 0===o)return"";if(null===o)return r(e,t);if(Array.isArray(o)){var u=[];return o.slice().forEach(function(n){void 0!==n&&(null===n?u.push(r(e,t)):u.push(r(e,t)+"="+r(n,t)))}),u.join("&")}return r(e,t)+"="+r(o,t)}).filter(function(n){return n.length>0}).join("&"):""}},function(n,t){"use strict";n.exports=function(n){return encodeURIComponent(n).replace(/[!'()*]/g,function(n){return"%"+n.charCodeAt(0).toString(16).toUpperCase()})}}])});
!function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.HTTPClient=t():n.HTTPClient=t()}(this,function(){return function(n){function t(r){if(e[r])return e[r].exports;var o=e[r]={exports:{},id:r,loaded:!1};return n[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var e={};return t.m=n,t.c=e,t.p="",t(0)}([function(n,t,e){"use strict";function r(n){return n&&n.__esModule?n:{"default":n}}Object.defineProperty(t,"__esModule",{value:!0}),t.requestInfo=t.debug=t.parseText=t.parseJSON=t.parse=t.onResponse=t.handleResponse=t.recv=t.params=t.json=t.body=t.query=t.base=t.accept=t.auth=t.header=t.method=t.init=t.fetch=t.createFetch=t.createStack=t.enhanceFetch=t.enableRecv=void 0;var o=e(3),u=e(1),i=r(u),c=(0,eval)("this"),a=function(n){return"string"==typeof n?n:(0,o.stringify)(n)},f=function(n){return"string"==typeof n?n:JSON.stringify(n)},s=function(n,t){return t.reduce(function(n,t){return n.then(t)},Promise.resolve(n))},p=t.enableRecv=function(n){return function(t){var e=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return n(t,e).then(function(n){var t=e.responseHandlers;return t&&t.length?s(n,t):n})}},l=(t.enhanceFetch=p,function(n,t,e){return n(t,e)}),d=t.createStack=function(){for(var n=arguments.length,t=Array(n),e=0;e<n;e++)t[e]=arguments[e];return 0===t.length?l:t.reduceRight(function(n,t){return function(e,r,o){return t(function(t,r){return n(e,t,r)},r,o)}})},h=(t.createFetch=function(){if(0===arguments.length)return c.fetch;var n=d.apply(void 0,arguments);return p(function(t){var e=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return n(c.fetch,t,e)})},p(c.fetch));t.fetch=h;var v=t.init=function(n,t){return function(e,r){var o=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return o[n]=t,e(r,o)}},g=(t.method=function(n){return v("method",n)},function(n,t,e){(n.headers||(n.headers={}))[t]=e}),b=t.header=function(n,t){return function(e,r){var o=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return g(o,n,t),e(r,o)}},y=(t.auth=function(n){return b("Authorization",n)},t.accept=function(n){return b("Accept",n)},t.base=function(n){return function(t,e,r){return t(n+(e||""),r)}},t.query=function(n){var t=a(n);return function(n,e,r){return n(e+(e.indexOf("?")===-1?"?":"&")+t,r)}}),j=t.body=function(n,t){return function(e,r){var o=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return o.body=n,null!=n.length&&g(o,"Content-Length",(0,i["default"])(n)),t&&g(o,"Content-Type",t),e(r,o)}},m=(t.json=function(n){return j(f(n),"application/json")},t.params=function(n){var t=a(n);return function(n,e){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],o=(r.method||"GET").toUpperCase(),u="GET"===o||"HEAD"===o?y(t):j(t,"application/x-www-form-urlencoded");return u(n,e,r)}},t.recv=function(n){return function(t,e){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return(r.responseHandlers||(r.responseHandlers=[])).push(n),t(e,r)}}),O=(t.handleResponse=m,t.onResponse=m,t.parse=function(n){var t=arguments.length<=1||void 0===arguments[1]?"body":arguments[1];return m(function(e){return t in e?e[t]:e[n]().then(function(n){return e[t]=n,e},function(t){throw new Error("parse('"+n+"') error: "+t.stack)})})});t.parseJSON=function(){var n=arguments.length<=0||void 0===arguments[0]?"jsonData":arguments[0];return O("json",n)},t.parseText=function(){var n=arguments.length<=0||void 0===arguments[0]?"textString":arguments[0];return O("text",n)},t.debug=function(){return function(n,t,e){return n(t,e).then(function(n){return n.debug={input:t,options:e},n},function(){var n=arguments.length<=0||void 0===arguments[0]?new Error:arguments[0];throw n.debug={input:t,options:e},n})}},t.requestInfo=function(){return function(n,t,e){return n(t,e).then(function(n){return n.requestInput=t,n.requestOptions=e,n},function(){var n=arguments.length<=0||void 0===arguments[0]?new Error:arguments[0];throw n.requestInput=t,n.requestOptions=e,n})}}},function(n,t){"use strict";n.exports=function(n){var t,e;if(!n)return 0;for(n=n.toString(),t=e=n.length;t--;){var r=n[t].charCodeAt();56320<=r&&r<=57343&&t--,127<r&&r<=2047?e++:2047<r&&r<=65535&&(e+=2)}return e}},function(n,t){"use strict";function e(n){if(null===n||void 0===n)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(n)}function r(){try{if(!Object.assign)return!1;var n=new String("abc");if(n[5]="de","5"===Object.getOwnPropertyNames(n)[0])return!1;for(var t={},e=0;e<10;e++)t["_"+String.fromCharCode(e)]=e;var r=Object.getOwnPropertyNames(t).map(function(n){return t[n]});if("0123456789"!==r.join(""))return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(n){o[n]=n}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(u){return!1}}var o=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable;n.exports=r()?Object.assign:function(n,t){for(var r,i,c=e(n),a=1;a<arguments.length;a++){r=Object(arguments[a]);for(var f in r)o.call(r,f)&&(c[f]=r[f]);if(Object.getOwnPropertySymbols){i=Object.getOwnPropertySymbols(r);for(var s=0;s<i.length;s++)u.call(r,i[s])&&(c[i[s]]=r[i[s]])}}return c}},function(n,t,e){"use strict";function r(n,t){return t.encode?t.strict?o(n):encodeURIComponent(n):n}var o=e(4),u=e(2);t.extract=function(n){return n.split("?")[1]||""},t.parse=function(n){var t=Object.create(null);return"string"!=typeof n?t:(n=n.trim().replace(/^(\?|#|&)/,""))?(n.split("&").forEach(function(n){var e=n.replace(/\+/g," ").split("="),r=e.shift(),o=e.length>0?e.join("="):void 0;r=decodeURIComponent(r),o=void 0===o?null:decodeURIComponent(o),void 0===t[r]?t[r]=o:Array.isArray(t[r])?t[r].push(o):t[r]=[t[r],o]}),t):t},t.stringify=function(n,t){var e={encode:!0,strict:!0};return t=u(e,t),n?Object.keys(n).sort().map(function(e){var o=n[e];if(void 0===o)return"";if(null===o)return r(e,t);if(Array.isArray(o)){var u=[];return o.slice().forEach(function(n){void 0!==n&&(null===n?u.push(r(e,t)):u.push(r(e,t)+"="+r(n,t)))}),u.join("&")}return r(e,t)+"="+r(o,t)}).filter(function(n){return n.length>0}).join("&"):""}},function(n,t){"use strict";n.exports=function(n){return encodeURIComponent(n).replace(/[!'()*]/g,function(n){return"%"+n.charCodeAt(0).toString(16).toUpperCase()})}}])});
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