@optique/core 0.6.3 → 0.6.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/dist/modifiers.cjs +46 -14
- package/dist/modifiers.js +46 -14
- package/package.json +1 -1
package/dist/modifiers.cjs
CHANGED
|
@@ -23,17 +23,33 @@ function optional(parser) {
|
|
|
23
23
|
}],
|
|
24
24
|
initialState: void 0,
|
|
25
25
|
parse(context) {
|
|
26
|
+
const innerState = typeof context.state === "undefined" ? parser.initialState : context.state[0];
|
|
26
27
|
const result = parser.parse({
|
|
27
28
|
...context,
|
|
28
|
-
state:
|
|
29
|
+
state: innerState
|
|
29
30
|
});
|
|
30
|
-
if (result.success)
|
|
31
|
+
if (result.success) {
|
|
32
|
+
if (result.next.state !== innerState || result.consumed.length === 0) return {
|
|
33
|
+
success: true,
|
|
34
|
+
next: {
|
|
35
|
+
...result.next,
|
|
36
|
+
state: [result.next.state]
|
|
37
|
+
},
|
|
38
|
+
consumed: result.consumed
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
success: true,
|
|
42
|
+
next: {
|
|
43
|
+
...result.next,
|
|
44
|
+
state: context.state
|
|
45
|
+
},
|
|
46
|
+
consumed: result.consumed
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (result.consumed === 0) return {
|
|
31
50
|
success: true,
|
|
32
|
-
next:
|
|
33
|
-
|
|
34
|
-
state: [result.next.state]
|
|
35
|
-
},
|
|
36
|
-
consumed: result.consumed
|
|
51
|
+
next: context,
|
|
52
|
+
consumed: []
|
|
37
53
|
};
|
|
38
54
|
return result;
|
|
39
55
|
},
|
|
@@ -105,17 +121,33 @@ function withDefault(parser, defaultValue, options) {
|
|
|
105
121
|
}],
|
|
106
122
|
initialState: void 0,
|
|
107
123
|
parse(context) {
|
|
124
|
+
const innerState = typeof context.state === "undefined" ? parser.initialState : context.state[0];
|
|
108
125
|
const result = parser.parse({
|
|
109
126
|
...context,
|
|
110
|
-
state:
|
|
127
|
+
state: innerState
|
|
111
128
|
});
|
|
112
|
-
if (result.success)
|
|
129
|
+
if (result.success) {
|
|
130
|
+
if (result.next.state !== innerState || result.consumed.length === 0) return {
|
|
131
|
+
success: true,
|
|
132
|
+
next: {
|
|
133
|
+
...result.next,
|
|
134
|
+
state: [result.next.state]
|
|
135
|
+
},
|
|
136
|
+
consumed: result.consumed
|
|
137
|
+
};
|
|
138
|
+
return {
|
|
139
|
+
success: true,
|
|
140
|
+
next: {
|
|
141
|
+
...result.next,
|
|
142
|
+
state: context.state
|
|
143
|
+
},
|
|
144
|
+
consumed: result.consumed
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
if (result.consumed === 0) return {
|
|
113
148
|
success: true,
|
|
114
|
-
next:
|
|
115
|
-
|
|
116
|
-
state: [result.next.state]
|
|
117
|
-
},
|
|
118
|
-
consumed: result.consumed
|
|
149
|
+
next: context,
|
|
150
|
+
consumed: []
|
|
119
151
|
};
|
|
120
152
|
return result;
|
|
121
153
|
},
|
package/dist/modifiers.js
CHANGED
|
@@ -23,17 +23,33 @@ function optional(parser) {
|
|
|
23
23
|
}],
|
|
24
24
|
initialState: void 0,
|
|
25
25
|
parse(context) {
|
|
26
|
+
const innerState = typeof context.state === "undefined" ? parser.initialState : context.state[0];
|
|
26
27
|
const result = parser.parse({
|
|
27
28
|
...context,
|
|
28
|
-
state:
|
|
29
|
+
state: innerState
|
|
29
30
|
});
|
|
30
|
-
if (result.success)
|
|
31
|
+
if (result.success) {
|
|
32
|
+
if (result.next.state !== innerState || result.consumed.length === 0) return {
|
|
33
|
+
success: true,
|
|
34
|
+
next: {
|
|
35
|
+
...result.next,
|
|
36
|
+
state: [result.next.state]
|
|
37
|
+
},
|
|
38
|
+
consumed: result.consumed
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
success: true,
|
|
42
|
+
next: {
|
|
43
|
+
...result.next,
|
|
44
|
+
state: context.state
|
|
45
|
+
},
|
|
46
|
+
consumed: result.consumed
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (result.consumed === 0) return {
|
|
31
50
|
success: true,
|
|
32
|
-
next:
|
|
33
|
-
|
|
34
|
-
state: [result.next.state]
|
|
35
|
-
},
|
|
36
|
-
consumed: result.consumed
|
|
51
|
+
next: context,
|
|
52
|
+
consumed: []
|
|
37
53
|
};
|
|
38
54
|
return result;
|
|
39
55
|
},
|
|
@@ -105,17 +121,33 @@ function withDefault(parser, defaultValue, options) {
|
|
|
105
121
|
}],
|
|
106
122
|
initialState: void 0,
|
|
107
123
|
parse(context) {
|
|
124
|
+
const innerState = typeof context.state === "undefined" ? parser.initialState : context.state[0];
|
|
108
125
|
const result = parser.parse({
|
|
109
126
|
...context,
|
|
110
|
-
state:
|
|
127
|
+
state: innerState
|
|
111
128
|
});
|
|
112
|
-
if (result.success)
|
|
129
|
+
if (result.success) {
|
|
130
|
+
if (result.next.state !== innerState || result.consumed.length === 0) return {
|
|
131
|
+
success: true,
|
|
132
|
+
next: {
|
|
133
|
+
...result.next,
|
|
134
|
+
state: [result.next.state]
|
|
135
|
+
},
|
|
136
|
+
consumed: result.consumed
|
|
137
|
+
};
|
|
138
|
+
return {
|
|
139
|
+
success: true,
|
|
140
|
+
next: {
|
|
141
|
+
...result.next,
|
|
142
|
+
state: context.state
|
|
143
|
+
},
|
|
144
|
+
consumed: result.consumed
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
if (result.consumed === 0) return {
|
|
113
148
|
success: true,
|
|
114
|
-
next:
|
|
115
|
-
|
|
116
|
-
state: [result.next.state]
|
|
117
|
-
},
|
|
118
|
-
consumed: result.consumed
|
|
149
|
+
next: context,
|
|
150
|
+
consumed: []
|
|
119
151
|
};
|
|
120
152
|
return result;
|
|
121
153
|
},
|