@oscarpalmer/atoms 0.173.0 → 0.173.2
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/dist/index.mjs +4 -2
- package/dist/query.mjs +5 -3
- package/package.json +1 -1
- package/plugin/get-string.js +1 -3
- package/src/query.ts +9 -3
package/dist/index.mjs
CHANGED
|
@@ -4078,13 +4078,14 @@ function getParts(value, fromArray, prefix) {
|
|
|
4078
4078
|
const full = join([prefix, fromArray ? void 0 : key], ".");
|
|
4079
4079
|
if (Array.isArray(val)) parts.push(...getParts(val, true, full));
|
|
4080
4080
|
else if (isPlainObject(val)) parts.push(...getParts(val, false, full));
|
|
4081
|
-
else if (isDecodable(val)) parts.push(`${tryEncode(full)}=${tryEncode(val)}`);
|
|
4082
|
-
else if (val instanceof Date) parts.push(`${tryEncode(full)}=${val.toJSON()}`);
|
|
4081
|
+
else if (isDecodable(val)) parts.push(`${getString(tryEncode(full))}=${getString(tryEncode(val))}`);
|
|
4082
|
+
else if (val instanceof Date) parts.push(`${getString(tryEncode(full))}=${val.toJSON()}`);
|
|
4083
4083
|
}
|
|
4084
4084
|
return parts;
|
|
4085
4085
|
}
|
|
4086
4086
|
function getQueryValue(value) {
|
|
4087
4087
|
if (EXPRESSION_BOOLEAN.test(value)) return value === TRUE;
|
|
4088
|
+
if (EXPRESSION_NOPARSE.test(value)) return value;
|
|
4088
4089
|
const asNumber = getNumber(value);
|
|
4089
4090
|
if (!Number.isNaN(asNumber)) return asNumber;
|
|
4090
4091
|
const parsed = Date.parse(value);
|
|
@@ -4112,6 +4113,7 @@ function toQuery(parameters) {
|
|
|
4112
4113
|
}
|
|
4113
4114
|
const EXPRESSION_ARRAY_SUFFIX = /\[\]$/;
|
|
4114
4115
|
const EXPRESSION_BOOLEAN = /^(false|true)$/;
|
|
4116
|
+
const EXPRESSION_NOPARSE = /[_]/;
|
|
4115
4117
|
const TRUE = "true";
|
|
4116
4118
|
const TYPES = new Set([
|
|
4117
4119
|
"boolean",
|
package/dist/query.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isPlainObject } from "./internal/is.mjs";
|
|
2
|
-
import { ignoreKey, join, tryDecode, tryEncode } from "./internal/string.mjs";
|
|
2
|
+
import { getString, ignoreKey, join, tryDecode, tryEncode } from "./internal/string.mjs";
|
|
3
3
|
import { getNumber } from "./internal/number.mjs";
|
|
4
4
|
import { setValue } from "./internal/value/set.mjs";
|
|
5
5
|
//#region src/query.ts
|
|
@@ -30,13 +30,14 @@ function getParts(value, fromArray, prefix) {
|
|
|
30
30
|
const full = join([prefix, fromArray ? void 0 : key], ".");
|
|
31
31
|
if (Array.isArray(val)) parts.push(...getParts(val, true, full));
|
|
32
32
|
else if (isPlainObject(val)) parts.push(...getParts(val, false, full));
|
|
33
|
-
else if (isDecodable(val)) parts.push(`${tryEncode(full)}=${tryEncode(val)}`);
|
|
34
|
-
else if (val instanceof Date) parts.push(`${tryEncode(full)}=${val.toJSON()}`);
|
|
33
|
+
else if (isDecodable(val)) parts.push(`${getString(tryEncode(full))}=${getString(tryEncode(val))}`);
|
|
34
|
+
else if (val instanceof Date) parts.push(`${getString(tryEncode(full))}=${val.toJSON()}`);
|
|
35
35
|
}
|
|
36
36
|
return parts;
|
|
37
37
|
}
|
|
38
38
|
function getQueryValue(value) {
|
|
39
39
|
if (EXPRESSION_BOOLEAN.test(value)) return value === TRUE;
|
|
40
|
+
if (EXPRESSION_NOPARSE.test(value)) return value;
|
|
40
41
|
const asNumber = getNumber(value);
|
|
41
42
|
if (!Number.isNaN(asNumber)) return asNumber;
|
|
42
43
|
const parsed = Date.parse(value);
|
|
@@ -64,6 +65,7 @@ function toQuery(parameters) {
|
|
|
64
65
|
}
|
|
65
66
|
const EXPRESSION_ARRAY_SUFFIX = /\[\]$/;
|
|
66
67
|
const EXPRESSION_BOOLEAN = /^(false|true)$/;
|
|
68
|
+
const EXPRESSION_NOPARSE = /[_]/;
|
|
67
69
|
const TRUE = "true";
|
|
68
70
|
const TYPES = new Set([
|
|
69
71
|
"boolean",
|
package/package.json
CHANGED
package/plugin/get-string.js
CHANGED
|
@@ -27,9 +27,7 @@ function isStringify(node) {
|
|
|
27
27
|
|
|
28
28
|
const message = "Prefer 'getString' (@oscarpalmer/atoms) instead of 'toString' and 'String'";
|
|
29
29
|
|
|
30
|
-
const selectors = [
|
|
31
|
-
`[callee.name="${stringName}"]`,
|
|
32
|
-
];
|
|
30
|
+
const selectors = [`[callee.name="String"]`];
|
|
33
31
|
|
|
34
32
|
export default {
|
|
35
33
|
message,
|
package/src/query.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {isPlainObject} from './internal/is';
|
|
2
2
|
import {getNumber} from './internal/number';
|
|
3
|
-
import {ignoreKey, join, tryDecode, tryEncode} from './internal/string';
|
|
3
|
+
import {getString, ignoreKey, join, tryDecode, tryEncode} from './internal/string';
|
|
4
4
|
import {setValue} from './internal/value/set';
|
|
5
5
|
import type {ArrayOrPlainObject, PlainObject} from './models';
|
|
6
6
|
|
|
@@ -50,9 +50,9 @@ function getParts(value: ArrayOrPlainObject, fromArray: boolean, prefix?: string
|
|
|
50
50
|
} else if (isPlainObject(val)) {
|
|
51
51
|
parts.push(...getParts(val, false, full));
|
|
52
52
|
} else if (isDecodable(val)) {
|
|
53
|
-
parts.push(`${tryEncode(full)}=${tryEncode(val)}`);
|
|
53
|
+
parts.push(`${getString(tryEncode(full))}=${getString(tryEncode(val))}`);
|
|
54
54
|
} else if (val instanceof Date) {
|
|
55
|
-
parts.push(`${tryEncode(full)}=${val.toJSON()}`);
|
|
55
|
+
parts.push(`${getString(tryEncode(full))}=${val.toJSON()}`);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -64,6 +64,10 @@ function getQueryValue(value: string): unknown {
|
|
|
64
64
|
return value === TRUE;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
if (EXPRESSION_NOPARSE.test(value)) {
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
|
|
67
71
|
const asNumber = getNumber(value);
|
|
68
72
|
|
|
69
73
|
if (!Number.isNaN(asNumber)) {
|
|
@@ -123,6 +127,8 @@ const EXPRESSION_ARRAY_SUFFIX = /\[\]$/;
|
|
|
123
127
|
|
|
124
128
|
const EXPRESSION_BOOLEAN = /^(false|true)$/;
|
|
125
129
|
|
|
130
|
+
const EXPRESSION_NOPARSE = /[_]/;
|
|
131
|
+
|
|
126
132
|
const TRUE = 'true';
|
|
127
133
|
|
|
128
134
|
const TYPES = new Set(['boolean', 'number', 'string']);
|