@dereekb/util 9.12.2 → 9.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/fetch/CHANGELOG.md +4 -0
- package/fetch/package.json +2 -2
- package/fetch/src/lib/url.d.ts +16 -4
- package/fetch/src/lib/url.js +44 -6
- package/fetch/src/lib/url.js.map +1 -1
- package/package.json +1 -1
- package/test/CHANGELOG.md +4 -0
- package/test/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [9.12.3](https://github.com/dereekb/dbx-components/compare/v9.12.2-dev...v9.12.3) (2022-11-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
## [9.12.2](https://github.com/dereekb/dbx-components/compare/v9.12.1-dev...v9.12.2) (2022-11-07)
|
|
6
10
|
|
|
7
11
|
|
package/fetch/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [9.12.3](https://github.com/dereekb/dbx-components/compare/v9.12.2-dev...v9.12.3) (2022-11-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
## [9.12.2](https://github.com/dereekb/dbx-components/compare/v9.12.1-dev...v9.12.2) (2022-11-07)
|
|
6
10
|
|
|
7
11
|
|
package/fetch/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/util/fetch",
|
|
3
|
-
"version": "9.12.
|
|
3
|
+
"version": "9.12.3",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"typings": "./src/index.d.ts",
|
|
6
6
|
"dependencies": {},
|
|
7
7
|
"peerDependencies": {
|
|
8
|
-
"@dereekb/util": "9.12.
|
|
8
|
+
"@dereekb/util": "9.12.3",
|
|
9
9
|
"lodash.isequal": "^4.5.0",
|
|
10
10
|
"make-error": "^1.3.0",
|
|
11
11
|
"class-validator": "^0.13.2",
|
package/fetch/src/lib/url.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArrayOrValue } from '@dereekb/util';
|
|
1
|
+
import { ArrayOrValue, Maybe } from '@dereekb/util';
|
|
2
2
|
export declare type SimpleFetchURLInput = URL | string;
|
|
3
3
|
export interface FetchURLConfiguration {
|
|
4
4
|
/**
|
|
@@ -14,8 +14,20 @@ export declare type FetchURLInput = SimpleFetchURLInput | FetchURLConfiguration;
|
|
|
14
14
|
export declare function fetchURL(input: FetchURLInput): URL;
|
|
15
15
|
export declare function isURL(input: unknown): input is URL;
|
|
16
16
|
export declare function isURLSearchParams(input: unknown): input is URLSearchParams;
|
|
17
|
-
export declare type FetchURLQueryParamsInput = URLSearchParams | FetchURLSearchParamsObject | Iterable<FetchURLQueryKeyValueTuple> | string;
|
|
18
|
-
export declare type
|
|
17
|
+
export declare type FetchURLQueryParamsInput = URLSearchParams | FetchURLSearchParamsObject | Iterable<FetchURLQueryKeyValueStringTuple> | Iterable<FetchURLQueryKeyValueTuple> | string;
|
|
18
|
+
export declare type FetchURLQueryKeyValueStringTuple = [string, string];
|
|
19
|
+
/**
|
|
20
|
+
* Converts the input
|
|
21
|
+
*
|
|
22
|
+
* @param input
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
export declare function fetchURLQueryKeyValueStringTuples(input: Iterable<FetchURLQueryKeyValueTuple>): FetchURLQueryKeyValueStringTuple[];
|
|
26
|
+
export declare type FetchURLQueryKeyValueTuple = [Maybe<FetchURLQueryKeyValueTupleKey>, Maybe<ArrayOrValue<Maybe<FetchURLQueryKeyValueTupleKeyValue>>>];
|
|
27
|
+
export declare type FetchURLQueryKeyValueTupleKey = string | number;
|
|
28
|
+
export declare type FetchURLQueryKeyValueTupleKeyValue = string | number | boolean;
|
|
19
29
|
export declare function queryParamsToSearchParams(input: FetchURLQueryParamsInput): URLSearchParams;
|
|
20
|
-
export declare type
|
|
30
|
+
export declare type FetchURLSearchTupleValueKey = string | number;
|
|
31
|
+
export declare type FetchURLSearchTupleValue = string | number;
|
|
32
|
+
export declare type FetchURLSearchParamsObject = Partial<Record<FetchURLQueryKeyValueTupleKey, Maybe<ArrayOrValue<FetchURLQueryKeyValueTupleKeyValue>>>>;
|
|
21
33
|
export declare function fetchURLSearchParamsObjectToURLSearchParams(input: FetchURLSearchParamsObject): URLSearchParams;
|
package/fetch/src/lib/url.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchURLSearchParamsObjectToURLSearchParams = exports.queryParamsToSearchParams = exports.isURLSearchParams = exports.isURL = exports.fetchURL = void 0;
|
|
3
|
+
exports.fetchURLSearchParamsObjectToURLSearchParams = exports.queryParamsToSearchParams = exports.fetchURLQueryKeyValueStringTuples = exports.isURLSearchParams = exports.isURL = exports.fetchURL = void 0;
|
|
4
4
|
const util_1 = require("@dereekb/util");
|
|
5
5
|
function fetchURL(input) {
|
|
6
6
|
let url;
|
|
@@ -31,18 +31,47 @@ function isURLSearchParams(input) {
|
|
|
31
31
|
return typeof input === 'object' && input instanceof URLSearchParams;
|
|
32
32
|
}
|
|
33
33
|
exports.isURLSearchParams = isURLSearchParams;
|
|
34
|
+
/**
|
|
35
|
+
* Converts the input
|
|
36
|
+
*
|
|
37
|
+
* @param input
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
function fetchURLQueryKeyValueStringTuples(input) {
|
|
41
|
+
const paramTuples = [];
|
|
42
|
+
(0, util_1.forEachInIterable)(input, (tuple) => {
|
|
43
|
+
const [key, values] = tuple;
|
|
44
|
+
// ignore null/undefined keys and values
|
|
45
|
+
if (key != null && values != null) {
|
|
46
|
+
const keyString = String(key);
|
|
47
|
+
(0, util_1.useIterableOrValue)(values, (value) => {
|
|
48
|
+
// ignore null/undefined values
|
|
49
|
+
if (value != null) {
|
|
50
|
+
paramTuples.push([keyString, String(value)]);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return paramTuples;
|
|
56
|
+
}
|
|
57
|
+
exports.fetchURLQueryKeyValueStringTuples = fetchURLQueryKeyValueStringTuples;
|
|
34
58
|
function queryParamsToSearchParams(input) {
|
|
59
|
+
let result;
|
|
35
60
|
if (isURLSearchParams(input)) {
|
|
36
61
|
// by url search params
|
|
37
|
-
|
|
62
|
+
result = input;
|
|
63
|
+
}
|
|
64
|
+
else if (typeof input === 'string') {
|
|
65
|
+
result = new URLSearchParams(input);
|
|
38
66
|
}
|
|
39
|
-
else if ((0, util_1.isIterable)(input)
|
|
67
|
+
else if ((0, util_1.isIterable)(input)) {
|
|
40
68
|
// By tuples
|
|
41
|
-
|
|
69
|
+
result = new URLSearchParams(fetchURLQueryKeyValueStringTuples(input));
|
|
42
70
|
}
|
|
43
71
|
else {
|
|
44
|
-
|
|
72
|
+
result = fetchURLSearchParamsObjectToURLSearchParams(input);
|
|
45
73
|
}
|
|
74
|
+
return result;
|
|
46
75
|
}
|
|
47
76
|
exports.queryParamsToSearchParams = queryParamsToSearchParams;
|
|
48
77
|
function fetchURLSearchParamsObjectToURLSearchParams(input) {
|
|
@@ -50,7 +79,16 @@ function fetchURLSearchParamsObjectToURLSearchParams(input) {
|
|
|
50
79
|
(0, util_1.forEachKeyValue)(input, {
|
|
51
80
|
forEach: (tuple) => {
|
|
52
81
|
const [key, values] = tuple;
|
|
53
|
-
|
|
82
|
+
// ignore null/undefined keys and values
|
|
83
|
+
if (key != null && values != null) {
|
|
84
|
+
const keyString = String(key);
|
|
85
|
+
(0, util_1.useIterableOrValue)(values, (x) => {
|
|
86
|
+
// ignore null/undefined values
|
|
87
|
+
if (x != null) {
|
|
88
|
+
paramTuples.push([keyString, String(x)]);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
54
92
|
}
|
|
55
93
|
});
|
|
56
94
|
return new URLSearchParams(paramTuples);
|
package/fetch/src/lib/url.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../../../../../packages/util/fetch/src/lib/url.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../../../../../packages/util/fetch/src/lib/url.ts"],"names":[],"mappings":";;;AAAA,wCAAqI;AAiBrI,SAAgB,QAAQ,CAAC,KAAoB;IAC3C,IAAI,GAAQ,CAAC;IAEb,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;KACtB;SAAM,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE;QACvB,GAAG,GAAG,KAAK,CAAC;KACb;SAAM;QACL,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAEpC,IAAI,KAAK,CAAC,WAAW,EAAE;YACrB,MAAM,YAAY,GAAG,yBAAyB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YAClE,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,YAAY,CAAC,QAAQ,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;SACvD;aAAM;YACL,GAAG,GAAG,OAAO,CAAC;SACf;KACF;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAnBD,4BAmBC;AAED,SAAgB,KAAK,CAAC,KAAc;IAClC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,YAAY,GAAG,CAAC;AAC3D,CAAC;AAFD,sBAEC;AAED,SAAgB,iBAAiB,CAAC,KAAc;IAC9C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,YAA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B,2CAA2C,CAAC,KAAiC;IAC3F,MAAM,WAAW,GAAuB,EAAE,CAAC;IAE3C,IAAA,sBAAe,EAAC,KAAmC,EAAE;QACnD,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACjB,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC;YAE5B,wCAAwC;YACxC,IAAI,GAAG,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,EAAE;gBACjC,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;gBAE9B,IAAA,yBAAkB,EAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE;oBAC/B,+BAA+B;oBAC/B,IAAI,CAAC,IAAI,IAAI,EAAE;wBACb,WAAW,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;qBAC1C;gBACH,CAAC,CAAC,CAAC;aACJ;QACH,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,IAAI,eAAe,CAAC,WAAW,CAAC,CAAC;AAC1C,CAAC;AAtBD,kGAsBC"}
|
package/package.json
CHANGED
package/test/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [9.12.3](https://github.com/dereekb/dbx-components/compare/v9.12.2-dev...v9.12.3) (2022-11-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
## [9.12.2](https://github.com/dereekb/dbx-components/compare/v9.12.1-dev...v9.12.2) (2022-11-07)
|
|
6
10
|
|
|
7
11
|
|
package/test/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/util/test",
|
|
3
|
-
"version": "9.12.
|
|
3
|
+
"version": "9.12.3",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"typings": "./src/index.d.ts",
|
|
7
7
|
"dependencies": {},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"@dereekb/util": "9.12.
|
|
9
|
+
"@dereekb/util": "9.12.3",
|
|
10
10
|
"lodash.isequal": "^4.5.0",
|
|
11
11
|
"make-error": "^1.3.0",
|
|
12
12
|
"class-validator": "^0.13.2",
|