@jplorg/jpl 2.0.0 → 2.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/esm/main.js +3474 -0
- package/dist/types/applyDefaults.d.ts +2 -0
- package/dist/types/builtins/funcContains.d.ts +3 -0
- package/dist/types/builtins/funcEndsWith.d.ts +3 -0
- package/dist/types/builtins/funcError.d.ts +3 -0
- package/dist/types/builtins/funcFromJSON.d.ts +3 -0
- package/dist/types/builtins/funcHas.d.ts +3 -0
- package/dist/types/builtins/funcIn.d.ts +3 -0
- package/dist/types/builtins/funcKeys.d.ts +3 -0
- package/dist/types/builtins/funcLength.d.ts +3 -0
- package/dist/types/builtins/funcNow.d.ts +3 -0
- package/dist/types/builtins/funcStartsWith.d.ts +3 -0
- package/dist/types/builtins/funcToJSON.d.ts +3 -0
- package/dist/types/builtins/funcToLowerCase.d.ts +3 -0
- package/dist/types/builtins/funcToNumber.d.ts +3 -0
- package/dist/types/builtins/funcToString.d.ts +3 -0
- package/dist/types/builtins/funcToUpperCase.d.ts +3 -0
- package/dist/types/builtins/funcTrim.d.ts +3 -0
- package/dist/types/builtins/funcTrimEnd.d.ts +3 -0
- package/dist/types/builtins/funcTrimStart.d.ts +3 -0
- package/dist/types/builtins/funcType.d.ts +3 -0
- package/dist/types/builtins/funcVoid.d.ts +3 -0
- package/dist/types/builtins/index.d.ts +2 -0
- package/dist/types/builtins/internals.d.ts +1 -0
- package/dist/types/builtins/math.d.ts +17 -0
- package/dist/types/createSingleton.d.ts +1 -0
- package/dist/types/interpreter/index.d.ts +21 -0
- package/dist/types/interpreter/parse.d.ts +194 -0
- package/{src/interpreter/parseFunction.js → dist/types/interpreter/parseFunction.d.ts} +2 -10
- package/dist/types/interpreter/system.d.ts +3 -0
- package/dist/types/interpreter/util.d.ts +89 -0
- package/dist/types/library/apply.d.ts +32 -0
- package/dist/types/library/definition.d.ts +79 -0
- package/dist/types/library/errors/adaptErrors.d.ts +6 -0
- package/dist/types/library/errors/enclosure.d.ts +6 -0
- package/dist/types/library/errors/error.d.ts +6 -0
- package/dist/types/library/errors/execution.d.ts +12 -0
- package/dist/types/library/errors/fatal.d.ts +4 -0
- package/dist/types/library/errors/runtime.d.ts +46 -0
- package/dist/types/library/errors/syntax.d.ts +7 -0
- package/{src/library/functions.js → dist/types/library/functions.d.ts} +9 -30
- package/dist/types/library/index.d.ts +19 -0
- package/dist/types/library/mux.d.ts +19 -0
- package/{src/library/ops/op.js → dist/types/library/ops/op.d.ts} +25 -49
- package/{src/library/ops/opa.js → dist/types/library/ops/opa.d.ts} +4 -7
- package/{src/library/ops/opc.js → dist/types/library/ops/opc.d.ts} +6 -11
- package/{src/library/ops/opm.js → dist/types/library/ops/opm.d.ts} +5 -9
- package/{src/library/ops/opu.js → dist/types/library/ops/opu.d.ts} +8 -15
- package/dist/types/library/runtimeScope.d.ts +23 -0
- package/dist/types/library/runtimeSignal.d.ts +25 -0
- package/dist/types/library/types.d.ts +97 -0
- package/dist/types/main.d.ts +19 -0
- package/dist/types/program/handler.d.ts +11 -0
- package/dist/types/program/index.d.ts +40 -0
- package/dist/types/program/ops/index.d.ts +5 -0
- package/dist/types/program/ops/opAccess/index.d.ts +10 -0
- package/dist/types/program/ops/opAccess/opaField.d.ts +10 -0
- package/dist/types/program/ops/opAccess/opaFunction.d.ts +10 -0
- package/dist/types/program/ops/opAccess/opaIter.d.ts +10 -0
- package/dist/types/program/ops/opAccess/opaSlice.d.ts +10 -0
- package/dist/types/program/ops/opAnd.d.ts +10 -0
- package/dist/types/program/ops/opArrayConstructor.d.ts +10 -0
- package/dist/types/program/ops/opAssignment/index.d.ts +10 -0
- package/dist/types/program/ops/opAssignment/opaAssignField.d.ts +10 -0
- package/dist/types/program/ops/opAssignment/opaAssignIter.d.ts +10 -0
- package/dist/types/program/ops/opAssignment/opaAssignSlice.d.ts +10 -0
- package/dist/types/program/ops/opAssignment/opuAddition.d.ts +10 -0
- package/dist/types/program/ops/opAssignment/opuDivision.d.ts +10 -0
- package/dist/types/program/ops/opAssignment/opuMultiplication.d.ts +10 -0
- package/dist/types/program/ops/opAssignment/opuNullCoalescence.d.ts +10 -0
- package/dist/types/program/ops/opAssignment/opuRemainder.d.ts +10 -0
- package/dist/types/program/ops/opAssignment/opuSet.d.ts +10 -0
- package/dist/types/program/ops/opAssignment/opuSubtraction.d.ts +10 -0
- package/dist/types/program/ops/opAssignment/opuUpdate.d.ts +10 -0
- package/dist/types/program/ops/opCalculation/index.d.ts +10 -0
- package/dist/types/program/ops/opCalculation/opmAddition.d.ts +10 -0
- package/dist/types/program/ops/opCalculation/opmDivision.d.ts +10 -0
- package/dist/types/program/ops/opCalculation/opmMultiplication.d.ts +10 -0
- package/dist/types/program/ops/opCalculation/opmRemainder.d.ts +10 -0
- package/dist/types/program/ops/opCalculation/opmSubtraction.d.ts +10 -0
- package/dist/types/program/ops/opComparison/index.d.ts +10 -0
- package/dist/types/program/ops/opComparison/opcEqual.d.ts +10 -0
- package/dist/types/program/ops/opComparison/opcGreater.d.ts +10 -0
- package/dist/types/program/ops/opComparison/opcGreaterEqual.d.ts +10 -0
- package/dist/types/program/ops/opComparison/opcLess.d.ts +10 -0
- package/dist/types/program/ops/opComparison/opcLessEqual.d.ts +10 -0
- package/dist/types/program/ops/opComparison/opcUnequal.d.ts +10 -0
- package/dist/types/program/ops/opConstant.d.ts +10 -0
- package/dist/types/program/ops/opConstantFalse.d.ts +10 -0
- package/dist/types/program/ops/opConstantNull.d.ts +10 -0
- package/dist/types/program/ops/opConstantTrue.d.ts +10 -0
- package/dist/types/program/ops/opFunctionDefinition.d.ts +10 -0
- package/dist/types/program/ops/opIf.d.ts +10 -0
- package/dist/types/program/ops/opInterpolatedString.d.ts +10 -0
- package/dist/types/program/ops/opNegation.d.ts +10 -0
- package/dist/types/program/ops/opNot.d.ts +10 -0
- package/dist/types/program/ops/opNullCoalescence.d.ts +10 -0
- package/dist/types/program/ops/opNumber.d.ts +10 -0
- package/dist/types/program/ops/opObjectConstructor.d.ts +10 -0
- package/dist/types/program/ops/opOr.d.ts +10 -0
- package/dist/types/program/ops/opOutputConcat.d.ts +10 -0
- package/dist/types/program/ops/opString.d.ts +10 -0
- package/dist/types/program/ops/opTry.d.ts +10 -0
- package/dist/types/program/ops/opVariable.d.ts +10 -0
- package/dist/types/program/ops/opVariableDefinition.d.ts +10 -0
- package/dist/types/program/ops/opVoid.d.ts +10 -0
- package/dist/types/program/ops/utils.d.ts +5 -0
- package/dist/types/program/params.d.ts +67 -0
- package/dist/types/runtime/index.d.ts +82 -0
- package/package.json +59 -49
- package/{repl.js → repl.ts} +85 -39
- package/lib/applyDefaults.js +0 -34
- package/lib/builtins/funcContains.js +0 -25
- package/lib/builtins/funcEndsWith.js +0 -21
- package/lib/builtins/funcError.js +0 -11
- package/lib/builtins/funcFromJSON.js +0 -26
- package/lib/builtins/funcHas.js +0 -24
- package/lib/builtins/funcIn.js +0 -24
- package/lib/builtins/funcKeys.js +0 -20
- package/lib/builtins/funcLength.js +0 -24
- package/lib/builtins/funcNow.js +0 -10
- package/lib/builtins/funcStartsWith.js +0 -21
- package/lib/builtins/funcToJSON.js +0 -10
- package/lib/builtins/funcToLowerCase.js +0 -17
- package/lib/builtins/funcToNumber.js +0 -26
- package/lib/builtins/funcToString.js +0 -10
- package/lib/builtins/funcToUpperCase.js +0 -17
- package/lib/builtins/funcTrim.js +0 -17
- package/lib/builtins/funcTrimEnd.js +0 -17
- package/lib/builtins/funcTrimStart.js +0 -17
- package/lib/builtins/funcType.js +0 -10
- package/lib/builtins/funcVoid.js +0 -10
- package/lib/builtins/index.js +0 -205
- package/lib/builtins/internals.js +0 -8
- package/lib/builtins/math.js +0 -40
- package/lib/builtins/native.js +0 -180
- package/lib/createSingleton.js +0 -14
- package/lib/index.js +0 -79
- package/lib/interpreter/index.js +0 -56
- package/lib/interpreter/parse.js +0 -2377
- package/lib/interpreter/parseFunction.js +0 -24
- package/lib/interpreter/system.js +0 -10
- package/lib/interpreter/util.js +0 -349
- package/lib/library/apply.js +0 -142
- package/lib/library/definition.js +0 -9
- package/lib/library/errors/adaptErrors.js +0 -34
- package/lib/library/errors/enclosure.js +0 -16
- package/lib/library/errors/error.js +0 -18
- package/lib/library/errors/execution.js +0 -20
- package/lib/library/errors/fatal.js +0 -15
- package/lib/library/errors/runtime.js +0 -78
- package/lib/library/errors/syntax.js +0 -17
- package/lib/library/functions.js +0 -82
- package/lib/library/index.js +0 -335
- package/lib/library/mux.js +0 -106
- package/lib/library/ops/index.js +0 -60
- package/lib/library/ops/op.js +0 -180
- package/lib/library/ops/opa.js +0 -41
- package/lib/library/ops/opc.js +0 -59
- package/lib/library/ops/opm.js +0 -50
- package/lib/library/ops/opu.js +0 -77
- package/lib/library/runtimeScope.js +0 -38
- package/lib/library/runtimeSignal.js +0 -72
- package/lib/library/types.js +0 -304
- package/lib/program/index.js +0 -101
- package/lib/program/ops/index.js +0 -61
- package/lib/program/ops/opAccess/index.js +0 -55
- package/lib/program/ops/opAccess/opaField.js +0 -50
- package/lib/program/ops/opAccess/opaFunction.js +0 -50
- package/lib/program/ops/opAccess/opaIter.js +0 -33
- package/lib/program/ops/opAccess/opaSlice.js +0 -46
- package/lib/program/ops/opAnd.js +0 -30
- package/lib/program/ops/opArrayConstructor.js +0 -20
- package/lib/program/ops/opAssignment/index.js +0 -90
- package/lib/program/ops/opAssignment/opaAssignField.js +0 -125
- package/lib/program/ops/opAssignment/opaAssignIter.js +0 -71
- package/lib/program/ops/opAssignment/opaAssignSlice.js +0 -101
- package/lib/program/ops/opAssignment/opuAddition.js +0 -31
- package/lib/program/ops/opAssignment/opuDivision.js +0 -31
- package/lib/program/ops/opAssignment/opuMultiplication.js +0 -31
- package/lib/program/ops/opAssignment/opuNullCoalescence.js +0 -25
- package/lib/program/ops/opAssignment/opuRemainder.js +0 -31
- package/lib/program/ops/opAssignment/opuSet.js +0 -19
- package/lib/program/ops/opAssignment/opuSubtraction.js +0 -31
- package/lib/program/ops/opAssignment/opuUpdate.js +0 -19
- package/lib/program/ops/opCalculation/index.js +0 -57
- package/lib/program/ops/opCalculation/opmAddition.js +0 -49
- package/lib/program/ops/opCalculation/opmDivision.js +0 -42
- package/lib/program/ops/opCalculation/opmMultiplication.js +0 -40
- package/lib/program/ops/opCalculation/opmRemainder.js +0 -34
- package/lib/program/ops/opCalculation/opmSubtraction.js +0 -53
- package/lib/program/ops/opComparison/index.js +0 -59
- package/lib/program/ops/opComparison/opcEqual.js +0 -19
- package/lib/program/ops/opComparison/opcGreater.js +0 -19
- package/lib/program/ops/opComparison/opcGreaterEqual.js +0 -19
- package/lib/program/ops/opComparison/opcLess.js +0 -19
- package/lib/program/ops/opComparison/opcLessEqual.js +0 -19
- package/lib/program/ops/opComparison/opcUnequal.js +0 -19
- package/lib/program/ops/opConstant.js +0 -18
- package/lib/program/ops/opConstantFalse.js +0 -16
- package/lib/program/ops/opConstantNull.js +0 -16
- package/lib/program/ops/opConstantTrue.js +0 -16
- package/lib/program/ops/opFunctionDefinition.js +0 -21
- package/lib/program/ops/opIf.js +0 -38
- package/lib/program/ops/opInterpolatedString.js +0 -24
- package/lib/program/ops/opNegation.js +0 -25
- package/lib/program/ops/opNot.js +0 -16
- package/lib/program/ops/opNullCoalescence.js +0 -34
- package/lib/program/ops/opNumber.js +0 -18
- package/lib/program/ops/opObjectConstructor.js +0 -37
- package/lib/program/ops/opOr.js +0 -30
- package/lib/program/ops/opOutputConcat.js +0 -19
- package/lib/program/ops/opString.js +0 -18
- package/lib/program/ops/opTry.js +0 -37
- package/lib/program/ops/opVariable.js +0 -20
- package/lib/program/ops/opVariableDefinition.js +0 -24
- package/lib/program/ops/opVoid.js +0 -16
- package/lib/program/ops/utils.js +0 -35
- package/lib/runtime/index.js +0 -258
- package/src/applyDefaults.js +0 -35
- package/src/builtins/funcContains.js +0 -27
- package/src/builtins/funcEndsWith.js +0 -21
- package/src/builtins/funcError.js +0 -7
- package/src/builtins/funcFromJSON.js +0 -24
- package/src/builtins/funcHas.js +0 -25
- package/src/builtins/funcIn.js +0 -25
- package/src/builtins/funcKeys.js +0 -20
- package/src/builtins/funcLength.js +0 -26
- package/src/builtins/funcNow.js +0 -5
- package/src/builtins/funcStartsWith.js +0 -21
- package/src/builtins/funcToJSON.js +0 -5
- package/src/builtins/funcToLowerCase.js +0 -20
- package/src/builtins/funcToNumber.js +0 -25
- package/src/builtins/funcToString.js +0 -5
- package/src/builtins/funcToUpperCase.js +0 -20
- package/src/builtins/funcTrim.js +0 -16
- package/src/builtins/funcTrimEnd.js +0 -16
- package/src/builtins/funcTrimStart.js +0 -16
- package/src/builtins/funcType.js +0 -5
- package/src/builtins/funcVoid.js +0 -5
- package/src/builtins/index.js +0 -193
- package/src/builtins/internals.js +0 -9
- package/src/builtins/math.js +0 -44
- package/src/createSingleton.js +0 -9
- package/src/index.js +0 -44
- package/src/interpreter/index.js +0 -48
- package/src/interpreter/parse.js +0 -1473
- package/src/interpreter/system.js +0 -5
- package/src/interpreter/util.js +0 -237
- package/src/library/apply.js +0 -135
- package/src/library/definition.js +0 -3
- package/src/library/errors/adaptErrors.js +0 -28
- package/src/library/errors/enclosure.js +0 -11
- package/src/library/errors/error.js +0 -14
- package/src/library/errors/execution.js +0 -15
- package/src/library/errors/fatal.js +0 -10
- package/src/library/errors/runtime.js +0 -71
- package/src/library/errors/syntax.js +0 -12
- package/src/library/index.js +0 -41
- package/src/library/mux.js +0 -98
- package/src/library/runtimeScope.js +0 -35
- package/src/library/runtimeSignal.js +0 -67
- package/src/library/types.js +0 -299
- package/src/program/index.js +0 -114
- package/src/program/ops/index.js +0 -82
- package/src/program/ops/opAccess/index.js +0 -55
- package/src/program/ops/opAccess/opaField.js +0 -58
- package/src/program/ops/opAccess/opaFunction.js +0 -52
- package/src/program/ops/opAccess/opaIter.js +0 -34
- package/src/program/ops/opAccess/opaSlice.js +0 -61
- package/src/program/ops/opAnd.js +0 -32
- package/src/program/ops/opArrayConstructor.js +0 -16
- package/src/program/ops/opAssignment/index.js +0 -102
- package/src/program/ops/opAssignment/opaAssignField.js +0 -156
- package/src/program/ops/opAssignment/opaAssignIter.js +0 -77
- package/src/program/ops/opAssignment/opaAssignSlice.js +0 -160
- package/src/program/ops/opAssignment/opuAddition.js +0 -29
- package/src/program/ops/opAssignment/opuDivision.js +0 -29
- package/src/program/ops/opAssignment/opuMultiplication.js +0 -29
- package/src/program/ops/opAssignment/opuNullCoalescence.js +0 -26
- package/src/program/ops/opAssignment/opuRemainder.js +0 -29
- package/src/program/ops/opAssignment/opuSet.js +0 -15
- package/src/program/ops/opAssignment/opuSubtraction.js +0 -29
- package/src/program/ops/opAssignment/opuUpdate.js +0 -15
- package/src/program/ops/opCalculation/index.js +0 -64
- package/src/program/ops/opCalculation/opmAddition.js +0 -63
- package/src/program/ops/opCalculation/opmDivision.js +0 -47
- package/src/program/ops/opCalculation/opmMultiplication.js +0 -52
- package/src/program/ops/opCalculation/opmRemainder.js +0 -49
- package/src/program/ops/opCalculation/opmSubtraction.js +0 -72
- package/src/program/ops/opComparison/index.js +0 -67
- package/src/program/ops/opComparison/opcEqual.js +0 -17
- package/src/program/ops/opComparison/opcGreater.js +0 -17
- package/src/program/ops/opComparison/opcGreaterEqual.js +0 -17
- package/src/program/ops/opComparison/opcLess.js +0 -17
- package/src/program/ops/opComparison/opcLessEqual.js +0 -17
- package/src/program/ops/opComparison/opcUnequal.js +0 -17
- package/src/program/ops/opConstant.js +0 -13
- package/src/program/ops/opConstantFalse.js +0 -11
- package/src/program/ops/opConstantNull.js +0 -11
- package/src/program/ops/opConstantTrue.js +0 -11
- package/src/program/ops/opFunctionDefinition.js +0 -17
- package/src/program/ops/opIf.js +0 -44
- package/src/program/ops/opInterpolatedString.js +0 -27
- package/src/program/ops/opNegation.js +0 -26
- package/src/program/ops/opNot.js +0 -11
- package/src/program/ops/opNullCoalescence.js +0 -36
- package/src/program/ops/opNumber.js +0 -13
- package/src/program/ops/opObjectConstructor.js +0 -40
- package/src/program/ops/opOr.js +0 -32
- package/src/program/ops/opOutputConcat.js +0 -17
- package/src/program/ops/opString.js +0 -13
- package/src/program/ops/opTry.js +0 -38
- package/src/program/ops/opVariable.js +0 -17
- package/src/program/ops/opVariableDefinition.js +0 -18
- package/src/program/ops/opVoid.js +0 -11
- package/src/program/ops/utils.js +0 -19
- package/src/runtime/index.js +0 -309
- /package/{src/builtins/native.js → dist/types/builtins/native.d.ts} +0 -0
- /package/{src/library/ops/index.js → dist/types/library/ops/index.d.ts} +0 -0
package/{repl.js → repl.ts}
RENAMED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import * as jpl from '@jplorg/jpl';
|
|
4
|
+
import pkg from '@jplorg/jpl/package.json' with { type: 'json' };
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import os from 'os';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import readline from 'readline';
|
|
9
9
|
|
|
10
10
|
const replKeys = [':', '!'];
|
|
11
11
|
const defaultReplKey = replKeys[0];
|
|
12
12
|
const defaultPrompt = '> ';
|
|
13
13
|
const multilinePrompt = '… ';
|
|
14
14
|
|
|
15
|
-
let multilineInput;
|
|
15
|
+
let multilineInput: string | null;
|
|
16
16
|
|
|
17
17
|
const homeDir = os.homedir();
|
|
18
|
-
const historyFile = homeDir
|
|
18
|
+
const historyFile = homeDir
|
|
19
|
+
? path.join(homeDir, '.jpl_repl_history')
|
|
20
|
+
: undefined;
|
|
19
21
|
|
|
20
22
|
const muted = !process.stdin.isTTY;
|
|
21
23
|
|
|
@@ -45,9 +47,13 @@ function readHistory() {
|
|
|
45
47
|
if (historyFile) {
|
|
46
48
|
rl.on('history', (history) => {
|
|
47
49
|
try {
|
|
48
|
-
fs.writeFileSync(
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
fs.writeFileSync(
|
|
51
|
+
historyFile,
|
|
52
|
+
history.filter(Boolean).reverse().join('\n') + '\n',
|
|
53
|
+
{
|
|
54
|
+
mode: 0o600,
|
|
55
|
+
},
|
|
56
|
+
);
|
|
51
57
|
} catch {
|
|
52
58
|
// ignore
|
|
53
59
|
}
|
|
@@ -61,25 +67,29 @@ rl.on('close', () => {
|
|
|
61
67
|
rl.on('SIGINT', () => {
|
|
62
68
|
if (multilineInput != null) {
|
|
63
69
|
multilineInput = null;
|
|
64
|
-
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
71
|
+
(rl as any).clearLine?.();
|
|
65
72
|
rl.setPrompt(defaultPrompt);
|
|
66
73
|
rl.prompt();
|
|
67
74
|
return undefined;
|
|
68
75
|
}
|
|
69
76
|
if (rl.cursor === 0) return process.exit(0);
|
|
70
|
-
process.stdout.write(
|
|
71
|
-
|
|
77
|
+
process.stdout.write(
|
|
78
|
+
`\nTo exit, press Ctrl+C again or type ${defaultReplKey}e`,
|
|
79
|
+
);
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
+
(rl as any).clearLine?.();
|
|
72
82
|
rl.prompt();
|
|
73
83
|
return undefined;
|
|
74
84
|
});
|
|
75
85
|
|
|
76
|
-
let keep;
|
|
77
|
-
let inputs;
|
|
78
|
-
let measureTime;
|
|
86
|
+
let keep: boolean;
|
|
87
|
+
let inputs: unknown[];
|
|
88
|
+
let measureTime: boolean;
|
|
79
89
|
|
|
80
90
|
main();
|
|
81
91
|
|
|
82
|
-
async function main() {
|
|
92
|
+
async function main(): Promise<void> {
|
|
83
93
|
if (!muted) {
|
|
84
94
|
console.log(`Welcome to JPL v${pkg.version}.`);
|
|
85
95
|
console.log(`Type "${defaultReplKey}h" for more information.\n`);
|
|
@@ -103,7 +113,7 @@ async function main() {
|
|
|
103
113
|
}
|
|
104
114
|
}
|
|
105
115
|
|
|
106
|
-
async function handle(input) {
|
|
116
|
+
async function handle(input: string): Promise<void> {
|
|
107
117
|
if (!keep || inputs.length === 0) inputs = [null];
|
|
108
118
|
|
|
109
119
|
const fullLine = (multilineInput ?? '') + input;
|
|
@@ -149,15 +159,22 @@ async function handle(input) {
|
|
|
149
159
|
const program = await jpl.parse(line);
|
|
150
160
|
console.log(JSON.stringify(program.definition, null, 2));
|
|
151
161
|
} catch (err) {
|
|
152
|
-
if (
|
|
162
|
+
if (
|
|
163
|
+
jpl.JPLSyntaxError.is(err) &&
|
|
164
|
+
(err as jpl.JPLSyntaxError).at >=
|
|
165
|
+
(err as jpl.JPLSyntaxError).src.length
|
|
166
|
+
) {
|
|
153
167
|
// program is incomplete -> request additional input
|
|
154
168
|
multilineInput = fullLine + '\n';
|
|
155
169
|
rl.setPrompt(multilinePrompt);
|
|
156
170
|
rl.prompt();
|
|
157
171
|
return undefined;
|
|
158
172
|
}
|
|
159
|
-
if (jpl.JPLSyntaxError.is(err))
|
|
160
|
-
|
|
173
|
+
if (jpl.JPLSyntaxError.is(err))
|
|
174
|
+
console.log(
|
|
175
|
+
`${(err as jpl.JPLSyntaxError).name ?? 'JPLError'}: ${(err as jpl.JPLSyntaxError).message}`,
|
|
176
|
+
);
|
|
177
|
+
else console.log((err as Error).stack);
|
|
161
178
|
}
|
|
162
179
|
break;
|
|
163
180
|
|
|
@@ -167,7 +184,9 @@ async function handle(input) {
|
|
|
167
184
|
break;
|
|
168
185
|
|
|
169
186
|
default:
|
|
170
|
-
console.log(
|
|
187
|
+
console.log(
|
|
188
|
+
`Error: unrecognized REPL command ${defaultReplKey}${command}\n`,
|
|
189
|
+
);
|
|
171
190
|
printHelp();
|
|
172
191
|
}
|
|
173
192
|
} else {
|
|
@@ -176,15 +195,20 @@ async function handle(input) {
|
|
|
176
195
|
rl.setPrompt(defaultPrompt);
|
|
177
196
|
try {
|
|
178
197
|
const program = await jpl.parse(line);
|
|
179
|
-
let before;
|
|
180
|
-
let diff;
|
|
198
|
+
let before: number;
|
|
199
|
+
let diff: number;
|
|
181
200
|
if (measureTime) before = Date.now();
|
|
182
201
|
inputs = await program.run(inputs);
|
|
183
|
-
if (measureTime) diff = Date.now() - before
|
|
184
|
-
console.log(
|
|
185
|
-
|
|
202
|
+
if (measureTime) diff = Date.now() - before!;
|
|
203
|
+
console.log(
|
|
204
|
+
inputs.map((output) => JSON.stringify(output, null, 2)).join(', '),
|
|
205
|
+
);
|
|
206
|
+
if (measureTime) console.log(` -> took ${diff! / 1000}s`);
|
|
186
207
|
} catch (err) {
|
|
187
|
-
if (
|
|
208
|
+
if (
|
|
209
|
+
jpl.JPLSyntaxError.is(err) &&
|
|
210
|
+
(err as jpl.JPLSyntaxError).at >= (err as jpl.JPLSyntaxError).src.length
|
|
211
|
+
) {
|
|
188
212
|
// program is incomplete -> request additional input
|
|
189
213
|
multilineInput = fullLine + '\n';
|
|
190
214
|
rl.setPrompt(multilinePrompt);
|
|
@@ -192,8 +216,10 @@ async function handle(input) {
|
|
|
192
216
|
return undefined;
|
|
193
217
|
}
|
|
194
218
|
if (jpl.JPLSyntaxError.is(err) || jpl.JPLExecutionError.is(err))
|
|
195
|
-
console.log(
|
|
196
|
-
|
|
219
|
+
console.log(
|
|
220
|
+
`${(err as jpl.JPLSyntaxError).name ?? 'JPLError'}: ${(err as jpl.JPLSyntaxError).message}`,
|
|
221
|
+
);
|
|
222
|
+
else console.log((err as Error).stack);
|
|
197
223
|
}
|
|
198
224
|
}
|
|
199
225
|
|
|
@@ -201,12 +227,24 @@ async function handle(input) {
|
|
|
201
227
|
return undefined;
|
|
202
228
|
}
|
|
203
229
|
|
|
204
|
-
function parseBool(
|
|
230
|
+
function parseBool(
|
|
231
|
+
input: string,
|
|
232
|
+
defaultValue: boolean,
|
|
233
|
+
label: string,
|
|
234
|
+
): boolean | null {
|
|
205
235
|
const b = input.trim().toLowerCase();
|
|
206
236
|
let v;
|
|
207
237
|
if (b.length === 0) v = defaultValue;
|
|
208
|
-
else if (
|
|
209
|
-
|
|
238
|
+
else if (
|
|
239
|
+
b === 'on' ||
|
|
240
|
+
['true', 'yes', 'enabled'].some((e) => e.startsWith(b))
|
|
241
|
+
)
|
|
242
|
+
v = true;
|
|
243
|
+
else if (
|
|
244
|
+
b === 'off' ||
|
|
245
|
+
['false', 'no', 'disabled'].some((e) => e.startsWith(b))
|
|
246
|
+
)
|
|
247
|
+
v = false;
|
|
210
248
|
if (typeof v === 'boolean') {
|
|
211
249
|
console.log(` -> ${label} ${v ? 'on' : 'off'}`);
|
|
212
250
|
return v;
|
|
@@ -215,11 +253,11 @@ function parseBool(input, defaultValue, label) {
|
|
|
215
253
|
return null;
|
|
216
254
|
}
|
|
217
255
|
|
|
218
|
-
function printBool(value) {
|
|
256
|
+
function printBool(value: boolean): string {
|
|
219
257
|
return `boolean (${value ? 'on' : 'off'})`;
|
|
220
258
|
}
|
|
221
259
|
|
|
222
|
-
function printHelp() {
|
|
260
|
+
function printHelp(): void {
|
|
223
261
|
const commands = [
|
|
224
262
|
['c', '', 'Clear the console screen'],
|
|
225
263
|
['e', '', 'Exit the REPL'],
|
|
@@ -230,7 +268,11 @@ function printHelp() {
|
|
|
230
268
|
printBool(keep),
|
|
231
269
|
'Set whether program output should be kept as input for the next program',
|
|
232
270
|
],
|
|
233
|
-
[
|
|
271
|
+
[
|
|
272
|
+
't',
|
|
273
|
+
printBool(measureTime),
|
|
274
|
+
'Set whether execution time should be measured',
|
|
275
|
+
],
|
|
234
276
|
['q', '', 'Exit the REPL'],
|
|
235
277
|
];
|
|
236
278
|
const aLen = commands.reduce((sum, [, a]) => Math.max(sum, a.length), 0);
|
|
@@ -241,8 +283,12 @@ function printHelp() {
|
|
|
241
283
|
);
|
|
242
284
|
|
|
243
285
|
commands.forEach(([c, a, d]) =>
|
|
244
|
-
console.log(
|
|
286
|
+
console.log(
|
|
287
|
+
`${defaultReplKey}${c} ${a}${' '.repeat(aLen - a.length + 3)}${d}`,
|
|
288
|
+
),
|
|
245
289
|
);
|
|
246
290
|
|
|
247
|
-
console.log(
|
|
291
|
+
console.log(
|
|
292
|
+
'\nPress Ctrl+C to abort current expression, Ctrl+D to exit the REPL',
|
|
293
|
+
);
|
|
248
294
|
}
|
package/lib/applyDefaults.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
/** Apply the specified defaults to the config */
|
|
8
|
-
function applyDefaults(config, defaults, ...strictPaths) {
|
|
9
|
-
const iter = (c, d, s) => {
|
|
10
|
-
if (Array.isArray(c)) return c;
|
|
11
|
-
if (typeof c === 'object') {
|
|
12
|
-
if (c === null || Array.isArray(d) || typeof d !== 'object' || d === null) return c;
|
|
13
|
-
const result = {
|
|
14
|
-
...c
|
|
15
|
-
};
|
|
16
|
-
const isStrict = s.some(entry => entry.length === 0);
|
|
17
|
-
Object.keys({
|
|
18
|
-
...c,
|
|
19
|
-
...d
|
|
20
|
-
}).forEach(key => {
|
|
21
|
-
if (isStrict) {
|
|
22
|
-
if (!Object.hasOwn(result, key)) result[key] = d[key];
|
|
23
|
-
} else {
|
|
24
|
-
result[key] = iter(result[key], d[key], s.filter(entry => entry[0] === key).map(entry => entry.slice(1)));
|
|
25
|
-
}
|
|
26
|
-
if (result[key] === undefined) delete result[key];
|
|
27
|
-
});
|
|
28
|
-
return result;
|
|
29
|
-
}
|
|
30
|
-
return c === undefined ? d : c;
|
|
31
|
-
};
|
|
32
|
-
return iter(config, defaults, strictPaths.map(path => typeof path === 'string' ? path.split('.') : path));
|
|
33
|
-
}
|
|
34
|
-
var _default = exports.default = applyDefaults;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _library = require("../library");
|
|
8
|
-
function builtin(runtime, signal, next, input, arg0) {
|
|
9
|
-
const value = runtime.unwrapValue(input);
|
|
10
|
-
const t = runtime.type(value);
|
|
11
|
-
const token = runtime.unwrapValue(arg0 ?? null);
|
|
12
|
-
const tt = runtime.type(token);
|
|
13
|
-
switch (t) {
|
|
14
|
-
case 'array':
|
|
15
|
-
return next(value.some(item => runtime.equals(item, token)));
|
|
16
|
-
case 'string':
|
|
17
|
-
if (tt === 'string') return next(value.includes(token));
|
|
18
|
-
break;
|
|
19
|
-
case 'object':
|
|
20
|
-
return next(Object.values(value).some(item => runtime.equals(item, token)));
|
|
21
|
-
default:
|
|
22
|
-
}
|
|
23
|
-
throw new _library.JPLTypeError('%s (%*<100v) cannot contain %s (%*<100v)', t, value, tt, token);
|
|
24
|
-
}
|
|
25
|
-
var _default = exports.default = builtin;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _library = require("../library");
|
|
8
|
-
function builtin(runtime, signal, next, input, arg0) {
|
|
9
|
-
const value = runtime.unwrapValue(input);
|
|
10
|
-
const t = runtime.type(value);
|
|
11
|
-
const token = runtime.unwrapValue(arg0 ?? null);
|
|
12
|
-
const tt = runtime.type(token);
|
|
13
|
-
switch (t) {
|
|
14
|
-
case 'string':
|
|
15
|
-
if (tt === 'string') return next(value.endsWith(token));
|
|
16
|
-
break;
|
|
17
|
-
default:
|
|
18
|
-
}
|
|
19
|
-
throw new _library.JPLTypeError('%s (%*<100v) cannot end with %s (%*<100v)', t, value, tt, token);
|
|
20
|
-
}
|
|
21
|
-
var _default = exports.default = builtin;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _library = require("../library");
|
|
8
|
-
function builtin(runtime, signal, next, input) {
|
|
9
|
-
throw new _library.JPLRuntimeError(input);
|
|
10
|
-
}
|
|
11
|
-
var _default = exports.default = builtin;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _library = require("../library");
|
|
8
|
-
function builtin(runtime, signal, next, input) {
|
|
9
|
-
const value = runtime.unwrapValue(input);
|
|
10
|
-
const t = runtime.type(value);
|
|
11
|
-
switch (t) {
|
|
12
|
-
case 'string':
|
|
13
|
-
{
|
|
14
|
-
let result;
|
|
15
|
-
try {
|
|
16
|
-
result = JSON.parse(value);
|
|
17
|
-
} catch (err) {
|
|
18
|
-
throw new _library.JPLRuntimeError(err.message);
|
|
19
|
-
}
|
|
20
|
-
return next(result);
|
|
21
|
-
}
|
|
22
|
-
default:
|
|
23
|
-
}
|
|
24
|
-
throw new _library.JPLTypeError('%s (%*<100v) cannot be parsed as JSON', t, value);
|
|
25
|
-
}
|
|
26
|
-
var _default = exports.default = builtin;
|
package/lib/builtins/funcHas.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _library = require("../library");
|
|
8
|
-
function builtin(runtime, signal, next, input, arg0) {
|
|
9
|
-
const value = runtime.unwrapValue(input);
|
|
10
|
-
const tv = runtime.type(value);
|
|
11
|
-
const key = runtime.unwrapValue(arg0 ?? null);
|
|
12
|
-
const tk = runtime.type(key);
|
|
13
|
-
switch (tv) {
|
|
14
|
-
case 'array':
|
|
15
|
-
if (tk === 'number') return next(key >= 0 && key < value.length);
|
|
16
|
-
break;
|
|
17
|
-
case 'object':
|
|
18
|
-
if (tk === 'string') return next(Object.hasOwn(value, key));
|
|
19
|
-
break;
|
|
20
|
-
default:
|
|
21
|
-
}
|
|
22
|
-
throw new _library.JPLTypeError('%s (%*<100v) cannot have %s (%*<100v) as key', tv, value, tk, key);
|
|
23
|
-
}
|
|
24
|
-
var _default = exports.default = builtin;
|
package/lib/builtins/funcIn.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _library = require("../library");
|
|
8
|
-
function builtin(runtime, signal, next, input, arg0) {
|
|
9
|
-
const key = runtime.unwrapValue(input);
|
|
10
|
-
const tk = runtime.type(key);
|
|
11
|
-
const value = runtime.unwrapValue(arg0 ?? null);
|
|
12
|
-
const tv = runtime.type(value);
|
|
13
|
-
switch (tv) {
|
|
14
|
-
case 'array':
|
|
15
|
-
if (tk === 'number') return next(key >= 0 && key < value.length);
|
|
16
|
-
break;
|
|
17
|
-
case 'object':
|
|
18
|
-
if (tk === 'string') return next(Object.hasOwn(value, key));
|
|
19
|
-
break;
|
|
20
|
-
default:
|
|
21
|
-
}
|
|
22
|
-
throw new _library.JPLTypeError('%s (%*<100v) cannot have %s (%*<100v) as key', tv, value, tk, key);
|
|
23
|
-
}
|
|
24
|
-
var _default = exports.default = builtin;
|
package/lib/builtins/funcKeys.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _library = require("../library");
|
|
8
|
-
function builtin(runtime, signal, next, input) {
|
|
9
|
-
const value = runtime.unwrapValue(input);
|
|
10
|
-
const t = runtime.type(value);
|
|
11
|
-
switch (t) {
|
|
12
|
-
case 'array':
|
|
13
|
-
return next(value.map((_, i) => i));
|
|
14
|
-
case 'object':
|
|
15
|
-
return next(Object.keys(value));
|
|
16
|
-
default:
|
|
17
|
-
}
|
|
18
|
-
throw new _library.JPLTypeError('%s (%*<100v) has no keys', t, value);
|
|
19
|
-
}
|
|
20
|
-
var _default = exports.default = builtin;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _library = require("../library");
|
|
8
|
-
function builtin(runtime, signal, next, input) {
|
|
9
|
-
const value = runtime.unwrapValue(input);
|
|
10
|
-
const t = runtime.type(value);
|
|
11
|
-
switch (t) {
|
|
12
|
-
case 'null':
|
|
13
|
-
return next(0);
|
|
14
|
-
case 'array':
|
|
15
|
-
return next(value.length);
|
|
16
|
-
case 'string':
|
|
17
|
-
return next([...value].length);
|
|
18
|
-
case 'object':
|
|
19
|
-
return next(Object.keys(value).length);
|
|
20
|
-
default:
|
|
21
|
-
}
|
|
22
|
-
throw new _library.JPLTypeError('%s (%*<100v) has no length', t, value);
|
|
23
|
-
}
|
|
24
|
-
var _default = exports.default = builtin;
|
package/lib/builtins/funcNow.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _library = require("../library");
|
|
8
|
-
function builtin(runtime, signal, next, input, arg0) {
|
|
9
|
-
const value = runtime.unwrapValue(input);
|
|
10
|
-
const t = runtime.type(value);
|
|
11
|
-
const token = runtime.unwrapValue(arg0 ?? null);
|
|
12
|
-
const tt = runtime.type(token);
|
|
13
|
-
switch (t) {
|
|
14
|
-
case 'string':
|
|
15
|
-
if (tt === 'string') return next(value.startsWith(token));
|
|
16
|
-
break;
|
|
17
|
-
default:
|
|
18
|
-
}
|
|
19
|
-
throw new _library.JPLTypeError('%s (%*<100v) cannot start with %s (%*<100v)', t, value, tt, token);
|
|
20
|
-
}
|
|
21
|
-
var _default = exports.default = builtin;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
function builtin(runtime, signal, next, input) {
|
|
8
|
-
return next(runtime.stringifyJSON(input, false));
|
|
9
|
-
}
|
|
10
|
-
var _default = exports.default = builtin;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _library = require("../library");
|
|
8
|
-
async function builtin(runtime, signal, next, input) {
|
|
9
|
-
const t = runtime.type(input);
|
|
10
|
-
switch (t) {
|
|
11
|
-
case 'string':
|
|
12
|
-
return next(await runtime.alterValue(input, value => value.toLowerCase()));
|
|
13
|
-
default:
|
|
14
|
-
}
|
|
15
|
-
throw new _library.JPLTypeError('%s (%*<100v) cannot be converted to lower case', t, runtime.unwrapValue(input));
|
|
16
|
-
}
|
|
17
|
-
var _default = exports.default = builtin;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _library = require("../library");
|
|
8
|
-
function builtin(runtime, signal, next, input) {
|
|
9
|
-
const value = runtime.unwrapValue(input);
|
|
10
|
-
const t = runtime.type(value);
|
|
11
|
-
switch (t) {
|
|
12
|
-
case 'number':
|
|
13
|
-
return next(value);
|
|
14
|
-
case 'string':
|
|
15
|
-
{
|
|
16
|
-
const result = runtime.normalizeValue(+value);
|
|
17
|
-
if (value === '' || runtime.type(result) !== 'number') {
|
|
18
|
-
throw new _library.JPLTypeConversionError('%s (%*<100v) does not contain a valid number', t, value);
|
|
19
|
-
}
|
|
20
|
-
return next(result);
|
|
21
|
-
}
|
|
22
|
-
default:
|
|
23
|
-
}
|
|
24
|
-
throw new _library.JPLTypeError('%s (%*<100v) cannot be parsed as a number', t, value);
|
|
25
|
-
}
|
|
26
|
-
var _default = exports.default = builtin;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
function builtin(runtime, signal, next, input) {
|
|
8
|
-
return next(runtime.stringifyJSON(input, true));
|
|
9
|
-
}
|
|
10
|
-
var _default = exports.default = builtin;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _library = require("../library");
|
|
8
|
-
async function builtin(runtime, signal, next, input) {
|
|
9
|
-
const t = runtime.type(input);
|
|
10
|
-
switch (t) {
|
|
11
|
-
case 'string':
|
|
12
|
-
return next(await runtime.alterValue(input, value => value.toUpperCase()));
|
|
13
|
-
default:
|
|
14
|
-
}
|
|
15
|
-
throw new _library.JPLTypeError('%s (%*<100v) cannot be converted to upper case', t, runtime.unwrapValue(input));
|
|
16
|
-
}
|
|
17
|
-
var _default = exports.default = builtin;
|
package/lib/builtins/funcTrim.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _library = require("../library");
|
|
8
|
-
async function builtin(runtime, signal, next, input) {
|
|
9
|
-
const t = runtime.type(input);
|
|
10
|
-
switch (t) {
|
|
11
|
-
case 'string':
|
|
12
|
-
return next(await runtime.alterValue(input, value => value.trim()));
|
|
13
|
-
default:
|
|
14
|
-
}
|
|
15
|
-
throw new _library.JPLTypeError('%s (%*<100v) cannot be trimmed', t, runtime.unwrapValue(input));
|
|
16
|
-
}
|
|
17
|
-
var _default = exports.default = builtin;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _library = require("../library");
|
|
8
|
-
async function builtin(runtime, signal, next, input) {
|
|
9
|
-
const t = runtime.type(input);
|
|
10
|
-
switch (t) {
|
|
11
|
-
case 'string':
|
|
12
|
-
return next(await runtime.alterValue(input, value => value.trimEnd()));
|
|
13
|
-
default:
|
|
14
|
-
}
|
|
15
|
-
throw new _library.JPLTypeError('%s (%*<100v) cannot be trimmed', t, runtime.unwrapValue(input));
|
|
16
|
-
}
|
|
17
|
-
var _default = exports.default = builtin;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _library = require("../library");
|
|
8
|
-
async function builtin(runtime, signal, next, input) {
|
|
9
|
-
const t = runtime.type(input);
|
|
10
|
-
switch (t) {
|
|
11
|
-
case 'string':
|
|
12
|
-
return next(await runtime.alterValue(input, value => value.trimStart()));
|
|
13
|
-
default:
|
|
14
|
-
}
|
|
15
|
-
throw new _library.JPLTypeError('%s (%*<100v) cannot be trimmed', t, runtime.unwrapValue(input));
|
|
16
|
-
}
|
|
17
|
-
var _default = exports.default = builtin;
|
package/lib/builtins/funcType.js
DELETED