exact-mirror 1.1.0 → 1.1.1
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/cjs/index.js +4 -3
- package/dist/index.mjs +4 -3
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -28,13 +28,14 @@ __export(index_exports, {
|
|
|
28
28
|
module.exports = __toCommonJS(index_exports);
|
|
29
29
|
var Kind = "~kind";
|
|
30
30
|
var Hint = "~hint";
|
|
31
|
-
var isSpecialProperty = (name) =>
|
|
31
|
+
var isSpecialProperty = (name) => !/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);
|
|
32
32
|
var joinProperty = (v1, v2, isOptional = false) => {
|
|
33
33
|
if (typeof v2 === "number") return `${v1}[${v2}]`;
|
|
34
|
-
if (isSpecialProperty(v2))
|
|
34
|
+
if (isSpecialProperty(v2))
|
|
35
|
+
return `${v1}${isOptional ? "?." : ""}[${JSON.stringify(v2)}]`;
|
|
35
36
|
return `${v1}${isOptional ? "?" : ""}.${v2}`;
|
|
36
37
|
};
|
|
37
|
-
var encodeProperty = (v) => isSpecialProperty(v) ?
|
|
38
|
+
var encodeProperty = (v) => isSpecialProperty(v) ? JSON.stringify(v) : v;
|
|
38
39
|
var sanitize = (key, sanitize2 = 0, schema) => {
|
|
39
40
|
if (schema.type !== "string" || schema.const || schema.trusted) return key;
|
|
40
41
|
let hof = "";
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
var Kind = "~kind";
|
|
3
3
|
var Hint = "~hint";
|
|
4
|
-
var isSpecialProperty = (name) =>
|
|
4
|
+
var isSpecialProperty = (name) => !/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);
|
|
5
5
|
var joinProperty = (v1, v2, isOptional = false) => {
|
|
6
6
|
if (typeof v2 === "number") return `${v1}[${v2}]`;
|
|
7
|
-
if (isSpecialProperty(v2))
|
|
7
|
+
if (isSpecialProperty(v2))
|
|
8
|
+
return `${v1}${isOptional ? "?." : ""}[${JSON.stringify(v2)}]`;
|
|
8
9
|
return `${v1}${isOptional ? "?" : ""}.${v2}`;
|
|
9
10
|
};
|
|
10
|
-
var encodeProperty = (v) => isSpecialProperty(v) ?
|
|
11
|
+
var encodeProperty = (v) => isSpecialProperty(v) ? JSON.stringify(v) : v;
|
|
11
12
|
var sanitize = (key, sanitize2 = 0, schema) => {
|
|
12
13
|
if (schema.type !== "string" || schema.const || schema.trusted) return key;
|
|
13
14
|
let hof = "";
|