typia 9.7.2 → 10.0.0-dev.20251107
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/LICENSE +21 -21
- package/README.md +153 -153
- package/lib/factories/ProtobufFactory.js +1 -1
- package/lib/factories/ProtobufFactory.mjs +1 -1
- package/lib/programmers/internal/json_schema_station.d.mts +2 -2
- package/lib/programmers/internal/json_schema_station.d.ts +2 -2
- package/lib/programmers/llm/LlmApplicationProgrammer.js +5 -1
- package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
- package/lib/programmers/llm/LlmApplicationProgrammer.mjs +5 -1
- package/lib/programmers/llm/LlmSchemaProgrammer.js +1 -4
- package/lib/programmers/llm/LlmSchemaProgrammer.js.map +1 -1
- package/lib/programmers/llm/LlmSchemaProgrammer.mjs +1 -35
- package/package.json +121 -121
- package/src/AssertionGuard.ts +41 -41
- package/src/CamelCase.ts +75 -75
- package/src/IRandomGenerator.ts +337 -337
- package/src/IReadableURLSearchParams.ts +9 -9
- package/src/PascalCase.ts +71 -71
- package/src/Primitive.ts +90 -90
- package/src/Resolved.ts +72 -72
- package/src/SnakeCase.ts +127 -127
- package/src/TypeGuardError.ts +216 -216
- package/src/factories/MetadataCollection.ts +270 -270
- package/src/factories/MetadataCommentTagFactory.ts +632 -632
- package/src/factories/MetadataFactory.ts +402 -402
- package/src/factories/ProtobufFactory.ts +873 -873
- package/src/functional.ts +705 -705
- package/src/http.ts +972 -972
- package/src/internal/_ProtobufReader.ts +188 -188
- package/src/internal/_ProtobufSizer.ts +137 -137
- package/src/internal/_ProtobufWriter.ts +135 -135
- package/src/internal/_jsonStringifyString.ts +42 -42
- package/src/json.ts +643 -643
- package/src/llm.ts +615 -615
- package/src/misc.ts +594 -594
- package/src/module.ts +889 -889
- package/src/notations.ts +751 -751
- package/src/programmers/FeatureProgrammer.ts +605 -605
- package/src/programmers/ImportProgrammer.ts +179 -179
- package/src/programmers/RandomProgrammer.ts +1195 -1195
- package/src/programmers/helpers/ProtobufWire.ts +34 -34
- package/src/programmers/internal/check_array_length.ts +43 -43
- package/src/programmers/internal/check_bigint.ts +46 -46
- package/src/programmers/internal/check_dynamic_key.ts +197 -197
- package/src/programmers/internal/check_dynamic_properties.ts +231 -231
- package/src/programmers/internal/check_everything.ts +21 -21
- package/src/programmers/internal/check_native.ts +23 -23
- package/src/programmers/internal/check_number.ts +108 -108
- package/src/programmers/internal/check_object.ts +72 -72
- package/src/programmers/internal/check_string.ts +46 -46
- package/src/programmers/internal/check_template.ts +46 -46
- package/src/programmers/internal/check_union_array_like.ts +331 -331
- package/src/programmers/internal/decode_union_object.ts +110 -110
- package/src/programmers/internal/feature_object_entries.ts +59 -59
- package/src/programmers/internal/json_schema_escaped.ts +78 -78
- package/src/programmers/internal/json_schema_object.ts +150 -150
- package/src/programmers/internal/json_schema_station.ts +2 -2
- package/src/programmers/internal/metadata_to_pattern.ts +40 -40
- package/src/programmers/internal/postfix_of_tuple.ts +3 -3
- package/src/programmers/internal/prune_object_properties.ts +69 -69
- package/src/programmers/internal/stringify_dynamic_properties.ts +158 -158
- package/src/programmers/internal/stringify_native.ts +5 -5
- package/src/programmers/internal/stringify_regular_properties.ts +77 -77
- package/src/programmers/internal/template_to_pattern.ts +21 -21
- package/src/programmers/internal/wrap_metadata_rest_tuple.ts +21 -21
- package/src/programmers/json/JsonStringifyProgrammer.ts +1124 -1124
- package/src/programmers/llm/LlmApplicationProgrammer.ts +10 -1
- package/src/programmers/llm/LlmSchemaProgrammer.ts +2 -7
- package/src/protobuf.ts +820 -820
- package/src/reflect.ts +46 -46
- package/src/schemas/json/IJsonApplication.ts +77 -77
- package/src/schemas/json/IJsonSchemaCollection.ts +212 -212
- package/src/schemas/json/IJsonSchemaUnit.ts +263 -263
- package/src/schemas/metadata/IMetadataTypeTag.ts +14 -14
- package/src/schemas/metadata/Metadata.ts +669 -669
- package/src/schemas/metadata/MetadataAliasType.ts +57 -57
- package/src/schemas/metadata/MetadataApplication.ts +40 -40
- package/src/schemas/metadata/MetadataArray.ts +47 -47
- package/src/schemas/metadata/MetadataArrayType.ts +51 -51
- package/src/schemas/metadata/MetadataAtomic.ts +85 -85
- package/src/schemas/metadata/MetadataEscaped.ts +45 -45
- package/src/schemas/metadata/MetadataFunction.ts +45 -45
- package/src/schemas/metadata/MetadataObject.ts +46 -46
- package/src/schemas/metadata/MetadataObjectType.ts +137 -137
- package/src/schemas/metadata/MetadataParameter.ts +52 -52
- package/src/schemas/metadata/MetadataProperty.ts +53 -53
- package/src/schemas/metadata/MetadataTemplate.ts +78 -78
- package/src/schemas/metadata/MetadataTuple.ts +28 -28
- package/src/schemas/metadata/MetadataTupleType.ts +61 -61
- package/src/tags/Constant.ts +47 -47
- package/src/tags/ContentMediaType.ts +27 -27
- package/src/tags/Default.ts +52 -52
- package/src/tags/Example.ts +56 -56
- package/src/tags/Examples.ts +56 -56
- package/src/tags/ExclusiveMaximum.ts +44 -44
- package/src/tags/ExclusiveMinimum.ts +44 -44
- package/src/tags/Format.ts +78 -78
- package/src/tags/JsonSchemaPlugin.ts +36 -36
- package/src/tags/MaxItems.ts +31 -31
- package/src/tags/MaxLength.ts +25 -25
- package/src/tags/Maximum.ts +39 -39
- package/src/tags/MinItems.ts +31 -31
- package/src/tags/MinLength.ts +25 -25
- package/src/tags/Minimum.ts +39 -39
- package/src/tags/MultipleOf.ts +42 -42
- package/src/tags/Pattern.ts +49 -49
- package/src/tags/Sequence.ts +37 -37
- package/src/tags/TagBase.ts +102 -102
- package/src/tags/Type.ts +64 -64
- package/src/tags/UniqueItems.ts +34 -34
- package/src/tags/internal/FormatCheatSheet.ts +71 -71
- package/src/transformers/ITransformOptions.ts +70 -70
- package/src/transformers/ImportTransformer.ts +253 -253
- package/src/transformers/NoTransformConfigurationError.ts +16 -16
- package/src/transformers/features/llm/LlmApplicationTransformer.ts +224 -224
- package/src/typings/Equal.ts +18 -18
|
@@ -1,135 +1,135 @@
|
|
|
1
|
-
import { Singleton } from "../utils/Singleton";
|
|
2
|
-
|
|
3
|
-
import { _IProtobufWriter } from "./_IProtobufWriter";
|
|
4
|
-
import { _ProtobufSizer } from "./_ProtobufSizer";
|
|
5
|
-
|
|
6
|
-
/// @reference https://github.com/piotr-oles/as-proto/blob/main/packages/as-proto/assembly/internal/FixedWriter.ts
|
|
7
|
-
export class _ProtobufWriter implements _IProtobufWriter {
|
|
8
|
-
/** Related sizer */
|
|
9
|
-
private readonly sizer: _ProtobufSizer;
|
|
10
|
-
|
|
11
|
-
/** Current pointer. */
|
|
12
|
-
private ptr: number;
|
|
13
|
-
|
|
14
|
-
/** Protobuf buffer. */
|
|
15
|
-
private buf: Uint8Array;
|
|
16
|
-
|
|
17
|
-
/** DataView for buffer. */
|
|
18
|
-
private view: DataView;
|
|
19
|
-
|
|
20
|
-
/** Index in varlen array from sizer. */
|
|
21
|
-
private varlenidx: number;
|
|
22
|
-
|
|
23
|
-
constructor(sizer: _ProtobufSizer) {
|
|
24
|
-
this.sizer = sizer;
|
|
25
|
-
this.buf = new Uint8Array(sizer.len);
|
|
26
|
-
this.view = new DataView(this.buf.buffer);
|
|
27
|
-
this.ptr = 0;
|
|
28
|
-
this.varlenidx = 0;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
buffer(): Uint8Array {
|
|
32
|
-
return this.buf;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
bool(value: boolean): void {
|
|
36
|
-
this.byte(value ? 1 : 0);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
byte(value: number): void {
|
|
40
|
-
this.buf[this.ptr++] = value & 255;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
int32(value: number): void {
|
|
44
|
-
if (value < 0) this.int64(value);
|
|
45
|
-
else this.variant32(value >>> 0);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
sint32(value: number): void {
|
|
49
|
-
this.variant32((value << 1) ^ (value >> 31));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
uint32(value: number): void {
|
|
53
|
-
this.variant32(value);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
sint64(value: number | bigint): void {
|
|
57
|
-
value = BigInt(value);
|
|
58
|
-
this.variant64((value << BigInt(0x01)) ^ (value >> BigInt(0x3f)));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
int64(value: number | bigint): void {
|
|
62
|
-
this.variant64(BigInt(value));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
uint64(value: number | bigint): void {
|
|
66
|
-
this.variant64(BigInt(value));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
float(val: number): void {
|
|
70
|
-
this.view.setFloat32(this.ptr, val, true);
|
|
71
|
-
this.ptr += 4;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
double(val: number): void {
|
|
75
|
-
this.view.setFloat64(this.ptr, val, true);
|
|
76
|
-
this.ptr += 8;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
bytes(value: Uint8Array): void {
|
|
80
|
-
this.uint32(value.byteLength);
|
|
81
|
-
for (let i = 0; i < value.byteLength; i++) this.buf[this.ptr++] = value[i]!;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
string(value: string): void {
|
|
85
|
-
const len: number = this.varlen(); // use precomputed length
|
|
86
|
-
this.uint32(len);
|
|
87
|
-
|
|
88
|
-
const binary: Uint8Array = utf8.get().encode(value);
|
|
89
|
-
for (let i = 0; i < binary.byteLength; i++)
|
|
90
|
-
this.buf[this.ptr++] = binary[i]!;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
fork(): void {
|
|
94
|
-
this.uint32(this.varlen()); // use precomputed length
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
ldelim(): void {
|
|
98
|
-
// nothing to do - all dirty work done by sizer
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
finish(): Uint8Array {
|
|
102
|
-
return this.buf;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
reset(): void {
|
|
106
|
-
this.buf = new Uint8Array(this.sizer.len);
|
|
107
|
-
this.view = new DataView(this.buf.buffer);
|
|
108
|
-
this.ptr = 0;
|
|
109
|
-
this.varlenidx = 0;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
private variant32(val: number): void {
|
|
113
|
-
while (val > 0x7f) {
|
|
114
|
-
this.buf[this.ptr++] = (val & 0x7f) | 0x80;
|
|
115
|
-
val = val >>> 7;
|
|
116
|
-
}
|
|
117
|
-
this.buf[this.ptr++] = val;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
private variant64(val: bigint): void {
|
|
121
|
-
val = BigInt.asUintN(64, val);
|
|
122
|
-
while (val > BigInt(0x7f)) {
|
|
123
|
-
this.buf[this.ptr++] = Number((val & BigInt(0x7f)) | BigInt(0x80));
|
|
124
|
-
val = val >> BigInt(0x07);
|
|
125
|
-
}
|
|
126
|
-
this.buf[this.ptr++] = Number(val);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
private varlen(): number {
|
|
130
|
-
return this.varlenidx >= this.sizer.varlen.length
|
|
131
|
-
? 0
|
|
132
|
-
: this.sizer.varlen[this.varlenidx++]!;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
const utf8 = /** @__PURE__ */ new Singleton(() => new TextEncoder());
|
|
1
|
+
import { Singleton } from "../utils/Singleton";
|
|
2
|
+
|
|
3
|
+
import { _IProtobufWriter } from "./_IProtobufWriter";
|
|
4
|
+
import { _ProtobufSizer } from "./_ProtobufSizer";
|
|
5
|
+
|
|
6
|
+
/// @reference https://github.com/piotr-oles/as-proto/blob/main/packages/as-proto/assembly/internal/FixedWriter.ts
|
|
7
|
+
export class _ProtobufWriter implements _IProtobufWriter {
|
|
8
|
+
/** Related sizer */
|
|
9
|
+
private readonly sizer: _ProtobufSizer;
|
|
10
|
+
|
|
11
|
+
/** Current pointer. */
|
|
12
|
+
private ptr: number;
|
|
13
|
+
|
|
14
|
+
/** Protobuf buffer. */
|
|
15
|
+
private buf: Uint8Array;
|
|
16
|
+
|
|
17
|
+
/** DataView for buffer. */
|
|
18
|
+
private view: DataView;
|
|
19
|
+
|
|
20
|
+
/** Index in varlen array from sizer. */
|
|
21
|
+
private varlenidx: number;
|
|
22
|
+
|
|
23
|
+
constructor(sizer: _ProtobufSizer) {
|
|
24
|
+
this.sizer = sizer;
|
|
25
|
+
this.buf = new Uint8Array(sizer.len);
|
|
26
|
+
this.view = new DataView(this.buf.buffer);
|
|
27
|
+
this.ptr = 0;
|
|
28
|
+
this.varlenidx = 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
buffer(): Uint8Array {
|
|
32
|
+
return this.buf;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
bool(value: boolean): void {
|
|
36
|
+
this.byte(value ? 1 : 0);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
byte(value: number): void {
|
|
40
|
+
this.buf[this.ptr++] = value & 255;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
int32(value: number): void {
|
|
44
|
+
if (value < 0) this.int64(value);
|
|
45
|
+
else this.variant32(value >>> 0);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
sint32(value: number): void {
|
|
49
|
+
this.variant32((value << 1) ^ (value >> 31));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
uint32(value: number): void {
|
|
53
|
+
this.variant32(value);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
sint64(value: number | bigint): void {
|
|
57
|
+
value = BigInt(value);
|
|
58
|
+
this.variant64((value << BigInt(0x01)) ^ (value >> BigInt(0x3f)));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
int64(value: number | bigint): void {
|
|
62
|
+
this.variant64(BigInt(value));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
uint64(value: number | bigint): void {
|
|
66
|
+
this.variant64(BigInt(value));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
float(val: number): void {
|
|
70
|
+
this.view.setFloat32(this.ptr, val, true);
|
|
71
|
+
this.ptr += 4;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
double(val: number): void {
|
|
75
|
+
this.view.setFloat64(this.ptr, val, true);
|
|
76
|
+
this.ptr += 8;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
bytes(value: Uint8Array): void {
|
|
80
|
+
this.uint32(value.byteLength);
|
|
81
|
+
for (let i = 0; i < value.byteLength; i++) this.buf[this.ptr++] = value[i]!;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
string(value: string): void {
|
|
85
|
+
const len: number = this.varlen(); // use precomputed length
|
|
86
|
+
this.uint32(len);
|
|
87
|
+
|
|
88
|
+
const binary: Uint8Array = utf8.get().encode(value);
|
|
89
|
+
for (let i = 0; i < binary.byteLength; i++)
|
|
90
|
+
this.buf[this.ptr++] = binary[i]!;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
fork(): void {
|
|
94
|
+
this.uint32(this.varlen()); // use precomputed length
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
ldelim(): void {
|
|
98
|
+
// nothing to do - all dirty work done by sizer
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
finish(): Uint8Array {
|
|
102
|
+
return this.buf;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
reset(): void {
|
|
106
|
+
this.buf = new Uint8Array(this.sizer.len);
|
|
107
|
+
this.view = new DataView(this.buf.buffer);
|
|
108
|
+
this.ptr = 0;
|
|
109
|
+
this.varlenidx = 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private variant32(val: number): void {
|
|
113
|
+
while (val > 0x7f) {
|
|
114
|
+
this.buf[this.ptr++] = (val & 0x7f) | 0x80;
|
|
115
|
+
val = val >>> 7;
|
|
116
|
+
}
|
|
117
|
+
this.buf[this.ptr++] = val;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
private variant64(val: bigint): void {
|
|
121
|
+
val = BigInt.asUintN(64, val);
|
|
122
|
+
while (val > BigInt(0x7f)) {
|
|
123
|
+
this.buf[this.ptr++] = Number((val & BigInt(0x7f)) | BigInt(0x80));
|
|
124
|
+
val = val >> BigInt(0x07);
|
|
125
|
+
}
|
|
126
|
+
this.buf[this.ptr++] = Number(val);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private varlen(): number {
|
|
130
|
+
return this.varlenidx >= this.sizer.varlen.length
|
|
131
|
+
? 0
|
|
132
|
+
: this.sizer.varlen[this.varlenidx++]!;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const utf8 = /** @__PURE__ */ new Singleton(() => new TextEncoder());
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* In the past, name of `typia` was `typescript-json`, and supported JSON
|
|
3
|
-
* serialization by wrapping `fast-json-stringify. `typescript-json`was a helper
|
|
4
|
-
* library of`fast-json-stringify`, which can skip manual JSON schema definition
|
|
5
|
-
* 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
|
-
* @reference https://github.com/fastify/fast-json-stringify/blob/master/lib/serializer.js
|
|
11
|
-
* @blog https://dev.to/samchon/good-bye-typescript-is-ancestor-of-typia-20000x-faster-validator-49fi
|
|
12
|
-
*/
|
|
13
|
-
export const _jsonStringifyString = (str: string): string => {
|
|
14
|
-
const len = str.length;
|
|
15
|
-
let result = "";
|
|
16
|
-
let last = -1;
|
|
17
|
-
let point = 255;
|
|
18
|
-
|
|
19
|
-
// eslint-disable-next-line
|
|
20
|
-
for (var i = 0; i < len; i++) {
|
|
21
|
-
point = str.charCodeAt(i);
|
|
22
|
-
if (point < 32) {
|
|
23
|
-
return JSON.stringify(str);
|
|
24
|
-
}
|
|
25
|
-
if (point >= 0xd800 && point <= 0xdfff) {
|
|
26
|
-
// The current character is a surrogate.
|
|
27
|
-
return JSON.stringify(str);
|
|
28
|
-
}
|
|
29
|
-
if (
|
|
30
|
-
point === 0x22 || // '"'
|
|
31
|
-
point === 0x5c // '\'
|
|
32
|
-
) {
|
|
33
|
-
last === -1 && (last = 0);
|
|
34
|
-
result += str.slice(last, i) + "\\";
|
|
35
|
-
last = i;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
(last === -1 && '"' + str + '"') || '"' + result + str.slice(last) + '"'
|
|
41
|
-
);
|
|
42
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* In the past, name of `typia` was `typescript-json`, and supported JSON
|
|
3
|
+
* serialization by wrapping `fast-json-stringify. `typescript-json`was a helper
|
|
4
|
+
* library of`fast-json-stringify`, which can skip manual JSON schema definition
|
|
5
|
+
* 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
|
+
* @reference https://github.com/fastify/fast-json-stringify/blob/master/lib/serializer.js
|
|
11
|
+
* @blog https://dev.to/samchon/good-bye-typescript-is-ancestor-of-typia-20000x-faster-validator-49fi
|
|
12
|
+
*/
|
|
13
|
+
export const _jsonStringifyString = (str: string): string => {
|
|
14
|
+
const len = str.length;
|
|
15
|
+
let result = "";
|
|
16
|
+
let last = -1;
|
|
17
|
+
let point = 255;
|
|
18
|
+
|
|
19
|
+
// eslint-disable-next-line
|
|
20
|
+
for (var i = 0; i < len; i++) {
|
|
21
|
+
point = str.charCodeAt(i);
|
|
22
|
+
if (point < 32) {
|
|
23
|
+
return JSON.stringify(str);
|
|
24
|
+
}
|
|
25
|
+
if (point >= 0xd800 && point <= 0xdfff) {
|
|
26
|
+
// The current character is a surrogate.
|
|
27
|
+
return JSON.stringify(str);
|
|
28
|
+
}
|
|
29
|
+
if (
|
|
30
|
+
point === 0x22 || // '"'
|
|
31
|
+
point === 0x5c // '\'
|
|
32
|
+
) {
|
|
33
|
+
last === -1 && (last = 0);
|
|
34
|
+
result += str.slice(last, i) + "\\";
|
|
35
|
+
last = i;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
(last === -1 && '"' + str + '"') || '"' + result + str.slice(last) + '"'
|
|
41
|
+
);
|
|
42
|
+
};
|