typia 4.1.15-dev.20230803 → 4.1.15-dev.20230803-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.
@@ -2,11 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.$string = void 0;
4
4
  var $string = function (str) {
5
- var len = str.length;
5
+ var length = str.length;
6
+ if (length > 41)
7
+ return JSON.stringify(str);
6
8
  var result = "";
7
9
  var last = -1;
8
10
  var point = 255;
9
- for (var i = 0; i < len; ++i) {
11
+ for (var i = 0; i < length; ++i) {
10
12
  point = str.charCodeAt(i);
11
13
  if (point < 32) {
12
14
  return JSON.stringify(str);
@@ -1 +1 @@
1
- {"version":3,"file":"$string.js","sourceRoot":"","sources":["../../src/functional/$string.ts"],"names":[],"mappings":";;;AAaO,IAAM,OAAO,GAAG,UAAC,GAAW;IAC/B,IAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC;IACvB,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC;IACd,IAAI,KAAK,GAAG,GAAG,CAAC;IAGhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;QAC1B,KAAK,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC1B,IAAI,KAAK,GAAG,EAAE,EAAE;YACZ,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;SAC9B;QACD,IAAI,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,MAAM,EAAE;YAEpC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;SAC9B;QACD,IACI,KAAK,KAAK,IAAI;YACd,KAAK,KAAK,IAAI,EAChB;YACE,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;YAC1B,MAAM,IAAI,GAAG,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E,CAAC,CAAC,GAAG,IAAI,CAAC;YACpC,IAAI,GAAG,CAAC,CAAC;SACZ;KACJ;IAED,OAAO,CACH,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,CAC3E,CAAC;AACN,CAAC,CAAC;AA/BW,QAAA,OAAO,WA+BlB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typia",
3
- "version": "4.1.15-dev.20230803",
3
+ "version": "4.1.15-dev.20230803-2",
4
4
  "description": "Superfast runtime validators with only one line",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -1,43 +1,45 @@
1
- /**
2
- * In the past, name of `typia` was `typescript-json`, and supported
3
- * JSON serialization by wrapping `fast-json-stringify. `typescript-json` was
4
- * a helper library of `fast-json-stringify`, which can skip manual JSON schema
5
- * definition just by putting pure TypeScript type.
6
- *
7
- * This `$string` function is a part of `fast-json-stringify` at that time, and
8
- * still being used in `typia` for the string serialization.
9
- *
10
- * @internal
11
- * @reference https://github.com/fastify/fast-json-stringify/blob/master/lib/serializer.js
12
- * @blog https://dev.to/samchon/good-bye-typescript-is-ancestor-of-typia-20000x-faster-validator-49fi
13
- */
14
- export const $string = (str: string): string => {
15
- const len = str.length;
16
- let result = "";
17
- let last = -1;
18
- let point = 255;
19
-
20
- // eslint-disable-next-line
21
- for (let i = 0; i < len; ++i) {
22
- point = str.charCodeAt(i);
23
- if (point < 32) {
24
- return JSON.stringify(str);
25
- }
26
- if (point >= 0xd800 && point <= 0xdfff) {
27
- // The current character is a surrogate.
28
- return JSON.stringify(str);
29
- }
30
- if (
31
- point === 0x22 || // '"'
32
- point === 0x5c // '\'
33
- ) {
34
- last === -1 && (last = 0);
35
- result += str.slice(last, i) + "\\";
36
- last = i;
37
- }
38
- }
39
-
40
- return (
41
- (last === -1 && '"' + str + '"') || '"' + result + str.slice(last) + '"'
42
- );
43
- };
1
+ /**
2
+ * In the past, name of `typia` was `typescript-json`, and supported
3
+ * JSON serialization by wrapping `fast-json-stringify. `typescript-json` was
4
+ * a helper library of `fast-json-stringify`, which can skip manual JSON schema
5
+ * definition just by putting pure TypeScript type.
6
+ *
7
+ * This `$string` function is a part of `fast-json-stringify` at that time, and
8
+ * still being used in `typia` for the string serialization.
9
+ *
10
+ * @internal
11
+ * @reference https://github.com/fastify/fast-json-stringify/blob/master/lib/serializer.js
12
+ * @blog https://dev.to/samchon/good-bye-typescript-is-ancestor-of-typia-20000x-faster-validator-49fi
13
+ */
14
+ export const $string = (str: string): string => {
15
+ const length = str.length;
16
+ if (length > 41) return JSON.stringify(str);
17
+
18
+ let result = "";
19
+ let last = -1;
20
+ let point = 255;
21
+
22
+ // eslint-disable-next-line
23
+ for (let i = 0; i < length; ++i) {
24
+ point = str.charCodeAt(i);
25
+ if (point < 32) {
26
+ return JSON.stringify(str);
27
+ }
28
+ if (point >= 0xd800 && point <= 0xdfff) {
29
+ // The current character is a surrogate.
30
+ return JSON.stringify(str);
31
+ }
32
+ if (
33
+ point === 0x22 || // '"'
34
+ point === 0x5c // '\'
35
+ ) {
36
+ last === -1 && (last = 0);
37
+ result += str.slice(last, i) + "\\";
38
+ last = i;
39
+ }
40
+ }
41
+
42
+ return (
43
+ (last === -1 && '"' + str + '"') || '"' + result + str.slice(last) + '"'
44
+ );
45
+ };