@tstdl/base 0.88.4 → 0.88.5
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/http/client/http-client.js +2 -2
- package/package.json +1 -1
- package/utils/merge.js +3 -3
- package/utils/type-guards.d.ts +6 -0
- package/utils/type-guards.js +8 -1
|
@@ -15,7 +15,7 @@ import { encodeUtf8 } from '../../utils/encoding.js';
|
|
|
15
15
|
import { composeAsyncMiddleware } from '../../utils/middleware.js';
|
|
16
16
|
import { objectEntries } from '../../utils/object/object.js';
|
|
17
17
|
import { readableStreamFromPromise } from '../../utils/stream/readable-stream-from-promise.js';
|
|
18
|
-
import { isDefined, isObject, isUndefined } from '../../utils/type-guards.js';
|
|
18
|
+
import { isArray, isDefined, isObject, isUndefined } from '../../utils/type-guards.js';
|
|
19
19
|
import { buildUrl } from '../../utils/url-builder.js';
|
|
20
20
|
import { HttpHeaders } from '../http-headers.js';
|
|
21
21
|
import { HttpError, HttpErrorReason } from '../http.error.js';
|
|
@@ -284,7 +284,7 @@ function mapParameters(request, baseUrl) {
|
|
|
284
284
|
if (request.mapParametersToQuery) {
|
|
285
285
|
for (const entry of parameterEntries) {
|
|
286
286
|
const [parameter, value] = entry;
|
|
287
|
-
if (isUndefined(value) || isObject(value)) {
|
|
287
|
+
if (isUndefined(value) || (isObject(value) && !isArray(value))) {
|
|
288
288
|
continue;
|
|
289
289
|
}
|
|
290
290
|
for (const val of toArray(value)) {
|
package/package.json
CHANGED
package/utils/merge.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
2
|
-
import { assertArray,
|
|
2
|
+
import { assertArray, assertLiteralObject, assertMap, assertSet, isArray, isLiteralObject, isMap, isSet, isUndefined } from './type-guards.js';
|
|
3
3
|
export function merge(a, b) {
|
|
4
4
|
if (isUndefined(a)) {
|
|
5
5
|
return b;
|
|
@@ -7,8 +7,8 @@ export function merge(a, b) {
|
|
|
7
7
|
if (isUndefined(b)) {
|
|
8
8
|
return a;
|
|
9
9
|
}
|
|
10
|
-
if (
|
|
11
|
-
|
|
10
|
+
if (isLiteralObject(a)) {
|
|
11
|
+
assertLiteralObject(b, 'Cannot merge object into non-object.');
|
|
12
12
|
return { ...a, ...b };
|
|
13
13
|
}
|
|
14
14
|
else if (isArray(a)) {
|
package/utils/type-guards.d.ts
CHANGED
|
@@ -78,6 +78,12 @@ export declare const assertSymbol: AssertFunction<symbol>;
|
|
|
78
78
|
export declare const assertNotSymbol: AssertNotFunction<symbol>;
|
|
79
79
|
export declare const assertSymbolPass: AssertPassFunction<symbol>;
|
|
80
80
|
export declare const assertNotSymbolPass: AssertNotPassFunction<symbol>;
|
|
81
|
+
export declare const isLiteralObject: IsFunction<object>;
|
|
82
|
+
export declare const isNotLiteralObject: IsNotFunction<object>;
|
|
83
|
+
export declare const assertLiteralObject: AssertFunction<object>;
|
|
84
|
+
export declare const assertNotLiteralObject: AssertNotFunction<object>;
|
|
85
|
+
export declare const assertLiteralObjectPass: AssertPassFunction<object>;
|
|
86
|
+
export declare const assertNotLiteralObjectPass: AssertNotPassFunction<object>;
|
|
81
87
|
export declare const isObject: IsFunction<object>;
|
|
82
88
|
export declare const isNotObject: IsNotFunction<object>;
|
|
83
89
|
export declare const assertObject: AssertFunction<object>;
|
package/utils/type-guards.js
CHANGED
|
@@ -104,7 +104,14 @@ export const assertSymbol = symbolGuards.assertSymbol;
|
|
|
104
104
|
export const assertNotSymbol = symbolGuards.assertNotSymbol;
|
|
105
105
|
export const assertSymbolPass = symbolGuards.assertSymbolPass;
|
|
106
106
|
export const assertNotSymbolPass = symbolGuards.assertNotSymbolPass;
|
|
107
|
-
const
|
|
107
|
+
const literalObjectGuards = createGuards('literal object', (value) => (typeof value == 'object') && (value != null) && (Reflect.getPrototypeOf(value) == Object.prototype) && (Reflect.getPrototypeOf(value).constructor == Object));
|
|
108
|
+
export const isLiteralObject = literalObjectGuards.isLiteralObject;
|
|
109
|
+
export const isNotLiteralObject = literalObjectGuards.isNotLiteralObject;
|
|
110
|
+
export const assertLiteralObject = literalObjectGuards.assertLiteralObject;
|
|
111
|
+
export const assertNotLiteralObject = literalObjectGuards.assertNotLiteralObject;
|
|
112
|
+
export const assertLiteralObjectPass = literalObjectGuards.assertLiteralObjectPass;
|
|
113
|
+
export const assertNotLiteralObjectPass = literalObjectGuards.assertNotLiteralObjectPass;
|
|
114
|
+
const objectGuards = createGuards('object', (value) => (typeof value == 'object') && (value != null));
|
|
108
115
|
export const isObject = objectGuards.isObject;
|
|
109
116
|
export const isNotObject = objectGuards.isNotObject;
|
|
110
117
|
export const assertObject = objectGuards.assertObject;
|