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

@apicase/adapter-xhr

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@apicase/adapter-xhr - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

27

index.cjs.js

@@ -7,10 +7,25 @@ 'use strict';

const encodeURIParts = (res, [key, val]) =>
res + encodeURIComponent(key) + '=' + encodeURIComponent(val);
const uriReducer = (res = [], [key, val]) =>
res.concat(
Array.isArray(val)
? val.reduce((res, val, i) => uriReducer(res, [`${key}[]`, val]), [])
: typeof val === 'object'
? Object.entries(val).reduce(
(res, [i, val]) => uriReducer(res, [`${key}[${i}]`, val]),
[]
)
: `${encodeURIComponent(key)}=${encodeURIComponent(val)}`
);
const buildQueryString = query => {
const queryString = Object.entries(query).reduce(encodeURIParts, '');
return queryString.length ? '?' + queryString : ''
};
const withQuestion = res => (res.length && `?${res}`) || '';
const buildQueryString = payload =>
withQuestion(
typeof payload === 'string'
? payload
: Object.entries(payload)
.reduce(uriReducer, [])
.join('&')
);
const defaultStatusValidator = status => status >= 200 && status < 300;

@@ -17,0 +32,0 @@

@@ -5,10 +5,25 @@ const pathToRegexp = require('path-to-regexp')

const encodeURIParts = (res, [key, val]) =>
res + encodeURIComponent(key) + '=' + encodeURIComponent(val)
const uriReducer = (res = [], [key, val]) =>
res.concat(
Array.isArray(val)
? val.reduce((res, val, i) => uriReducer(res, [`${key}[]`, val]), [])
: typeof val === 'object'
? Object.entries(val).reduce(
(res, [i, val]) => uriReducer(res, [`${key}[${i}]`, val]),
[]
)
: `${encodeURIComponent(key)}=${encodeURIComponent(val)}`
)
const buildQueryString = query => {
const queryString = Object.entries(query).reduce(encodeURIParts, '')
return queryString.length ? '?' + queryString : ''
}
const withQuestion = res => (res.length && `?${res}`) || ''
const buildQueryString = payload =>
withQuestion(
typeof payload === 'string'
? payload
: Object.entries(payload)
.reduce(uriReducer, [])
.join('&')
)
const defaultStatusValidator = status => status >= 200 && status < 300

@@ -15,0 +30,0 @@

{
"name": "@apicase/adapter-xhr",
"version": "0.5.0",
"version": "0.6.0",
"description": "XHR adapter for apicase-core",

@@ -5,0 +5,0 @@ "main": "index.cjs.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