@optique/core 0.9.0-dev.229 → 0.9.0-dev.231
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 +19 -52
- package/dist/modifiers.js +19 -52
- package/package.json +1 -1
package/dist/modifiers.cjs
CHANGED
|
@@ -269,62 +269,29 @@ function withDefault(parser, defaultValue, options) {
|
|
|
269
269
|
* ```
|
|
270
270
|
*/
|
|
271
271
|
function map(parser, transform) {
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
272
|
+
const complete = (state) => {
|
|
273
|
+
const res = parser.complete(state);
|
|
274
|
+
if (res instanceof Promise) return res.then((r) => {
|
|
275
|
+
if (r.success) return {
|
|
276
|
+
success: true,
|
|
277
|
+
value: transform(r.value)
|
|
278
|
+
};
|
|
279
|
+
return r;
|
|
280
|
+
});
|
|
281
|
+
if (res.success) return {
|
|
282
|
+
success: true,
|
|
283
|
+
value: transform(res.value)
|
|
284
|
+
};
|
|
285
|
+
return res;
|
|
286
|
+
};
|
|
287
|
+
return {
|
|
288
|
+
...parser,
|
|
283
289
|
$valueType: [],
|
|
284
|
-
|
|
285
|
-
priority: parser.priority,
|
|
286
|
-
usage: parser.usage,
|
|
287
|
-
initialState: parser.initialState,
|
|
288
|
-
parse(context) {
|
|
289
|
-
if (isAsync) return parser.parse(context);
|
|
290
|
-
return syncParser.parse(context);
|
|
291
|
-
},
|
|
292
|
-
complete(state) {
|
|
293
|
-
if (!isAsync) {
|
|
294
|
-
const innerResult = syncParser.complete(state);
|
|
295
|
-
if (innerResult.success) return {
|
|
296
|
-
success: true,
|
|
297
|
-
value: transform(innerResult.value)
|
|
298
|
-
};
|
|
299
|
-
return {
|
|
300
|
-
success: false,
|
|
301
|
-
error: innerResult.error
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
return (async () => {
|
|
305
|
-
const innerResult = await parser.complete(state);
|
|
306
|
-
if (innerResult.success) return {
|
|
307
|
-
success: true,
|
|
308
|
-
value: transform(innerResult.value)
|
|
309
|
-
};
|
|
310
|
-
return {
|
|
311
|
-
success: false,
|
|
312
|
-
error: innerResult.error
|
|
313
|
-
};
|
|
314
|
-
})();
|
|
315
|
-
},
|
|
316
|
-
suggest(context, prefix) {
|
|
317
|
-
if (isAsync) return suggestAsync(context, prefix);
|
|
318
|
-
return suggestSync(context, prefix);
|
|
319
|
-
},
|
|
290
|
+
complete,
|
|
320
291
|
getDocFragments(state, _defaultValue) {
|
|
321
|
-
return
|
|
292
|
+
return parser.getDocFragments(state, void 0);
|
|
322
293
|
}
|
|
323
294
|
};
|
|
324
|
-
return {
|
|
325
|
-
...result,
|
|
326
|
-
$mode: parser.$mode
|
|
327
|
-
};
|
|
328
295
|
}
|
|
329
296
|
/**
|
|
330
297
|
* Creates a parser that allows multiple occurrences of a given parser.
|
package/dist/modifiers.js
CHANGED
|
@@ -269,62 +269,29 @@ function withDefault(parser, defaultValue, options) {
|
|
|
269
269
|
* ```
|
|
270
270
|
*/
|
|
271
271
|
function map(parser, transform) {
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
272
|
+
const complete = (state) => {
|
|
273
|
+
const res = parser.complete(state);
|
|
274
|
+
if (res instanceof Promise) return res.then((r) => {
|
|
275
|
+
if (r.success) return {
|
|
276
|
+
success: true,
|
|
277
|
+
value: transform(r.value)
|
|
278
|
+
};
|
|
279
|
+
return r;
|
|
280
|
+
});
|
|
281
|
+
if (res.success) return {
|
|
282
|
+
success: true,
|
|
283
|
+
value: transform(res.value)
|
|
284
|
+
};
|
|
285
|
+
return res;
|
|
286
|
+
};
|
|
287
|
+
return {
|
|
288
|
+
...parser,
|
|
283
289
|
$valueType: [],
|
|
284
|
-
|
|
285
|
-
priority: parser.priority,
|
|
286
|
-
usage: parser.usage,
|
|
287
|
-
initialState: parser.initialState,
|
|
288
|
-
parse(context) {
|
|
289
|
-
if (isAsync) return parser.parse(context);
|
|
290
|
-
return syncParser.parse(context);
|
|
291
|
-
},
|
|
292
|
-
complete(state) {
|
|
293
|
-
if (!isAsync) {
|
|
294
|
-
const innerResult = syncParser.complete(state);
|
|
295
|
-
if (innerResult.success) return {
|
|
296
|
-
success: true,
|
|
297
|
-
value: transform(innerResult.value)
|
|
298
|
-
};
|
|
299
|
-
return {
|
|
300
|
-
success: false,
|
|
301
|
-
error: innerResult.error
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
return (async () => {
|
|
305
|
-
const innerResult = await parser.complete(state);
|
|
306
|
-
if (innerResult.success) return {
|
|
307
|
-
success: true,
|
|
308
|
-
value: transform(innerResult.value)
|
|
309
|
-
};
|
|
310
|
-
return {
|
|
311
|
-
success: false,
|
|
312
|
-
error: innerResult.error
|
|
313
|
-
};
|
|
314
|
-
})();
|
|
315
|
-
},
|
|
316
|
-
suggest(context, prefix) {
|
|
317
|
-
if (isAsync) return suggestAsync(context, prefix);
|
|
318
|
-
return suggestSync(context, prefix);
|
|
319
|
-
},
|
|
290
|
+
complete,
|
|
320
291
|
getDocFragments(state, _defaultValue) {
|
|
321
|
-
return
|
|
292
|
+
return parser.getDocFragments(state, void 0);
|
|
322
293
|
}
|
|
323
294
|
};
|
|
324
|
-
return {
|
|
325
|
-
...result,
|
|
326
|
-
$mode: parser.$mode
|
|
327
|
-
};
|
|
328
295
|
}
|
|
329
296
|
/**
|
|
330
297
|
* Creates a parser that allows multiple occurrences of a given parser.
|