@funboxteam/diamonds
Advanced tools
Comparing version 8.0.0 to 8.1.0
# Changelog | ||
## 8.1.0 (19.02.2021) | ||
Support arrays of primitive types in [objectToQueryString](./lib/object-to-query-string.ts). | ||
## 8.0.0 (17.02.2021) | ||
@@ -4,0 +9,0 @@ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var join = function (obj) { return Object.keys(obj) | ||
.map(function (key) { return key + "=" + encodeURIComponent(obj[key]); }) | ||
.reduce(function (acc, key) { | ||
var value = obj[key]; | ||
if (Array.isArray(value)) { | ||
return acc.concat(value.map(function (item) { return key + "=" + encodeURIComponent(item); })); | ||
} | ||
return acc.concat(key + "=" + encodeURIComponent(value)); | ||
}, []) | ||
.join('&'); }; | ||
exports.default = (function (params) { return "?" + join(params); }); |
var join = function (obj) { return Object.keys(obj) | ||
.map(function (key) { return key + "=" + encodeURIComponent(obj[key]); }) | ||
.reduce(function (acc, key) { | ||
var value = obj[key]; | ||
if (Array.isArray(value)) { | ||
return acc.concat(value.map(function (item) { return key + "=" + encodeURIComponent(item); })); | ||
} | ||
return acc.concat(key + "=" + encodeURIComponent(value)); | ||
}, []) | ||
.join('&'); }; | ||
export default (function (params) { return "?" + join(params); }); |
@@ -1,3 +0,3 @@ | ||
declare type QueryStringValue = string | number | boolean; | ||
declare type QueryStringValue = string | number | boolean | (string | number | boolean)[]; | ||
declare const _default: (params: Record<string, QueryStringValue>) => string; | ||
export default _default; |
{ | ||
"name": "@funboxteam/diamonds", | ||
"version": "8.0.0", | ||
"version": "8.1.0", | ||
"description": "A shiny pile of typed JS helpers for everyday use", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -242,3 +242,3 @@ # @funboxteam/diamonds | ||
Converts the passed object which contains primitive values into the query string. | ||
Converts the passed object which contains primitive values or arrays of primitive values into the query string. | ||
@@ -245,0 +245,0 @@ ### [omit](./lib/omit.ts) |
@@ -249,4 +249,4 @@ # @funboxteam/diamonds | ||
Превращает объект, в котором значения ключей представлены примитивными типами, | ||
в query-строку. | ||
Превращает объект, в котором значения ключей представлены примитивными типами или массивами | ||
примитивных типов, в query-строку. | ||
@@ -253,0 +253,0 @@ ### [omit](./lib/omit.ts) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
78299
1155