@jplorg/jpl 1.5.0 → 2.1.0
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 +18 -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 +12 -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 +11 -0
- package/dist/types/program/ops/opAccess/opaField.d.ts +11 -0
- package/dist/types/program/ops/opAccess/opaFunction.d.ts +11 -0
- package/dist/types/program/ops/opAccess/opaIter.d.ts +11 -0
- package/dist/types/program/ops/opAccess/opaSlice.d.ts +11 -0
- package/dist/types/program/ops/opAnd.d.ts +11 -0
- package/dist/types/program/ops/opArrayConstructor.d.ts +11 -0
- package/dist/types/program/ops/opAssignment/index.d.ts +11 -0
- package/dist/types/program/ops/opAssignment/opaAssignField.d.ts +11 -0
- package/dist/types/program/ops/opAssignment/opaAssignIter.d.ts +11 -0
- package/dist/types/program/ops/opAssignment/opaAssignSlice.d.ts +11 -0
- package/dist/types/program/ops/opAssignment/opuAddition.d.ts +11 -0
- package/dist/types/program/ops/opAssignment/opuDivision.d.ts +11 -0
- package/dist/types/program/ops/opAssignment/opuMultiplication.d.ts +11 -0
- package/dist/types/program/ops/opAssignment/opuNullCoalescence.d.ts +11 -0
- package/dist/types/program/ops/opAssignment/opuRemainder.d.ts +11 -0
- package/dist/types/program/ops/opAssignment/opuSet.d.ts +11 -0
- package/dist/types/program/ops/opAssignment/opuSubtraction.d.ts +11 -0
- package/dist/types/program/ops/opAssignment/opuUpdate.d.ts +11 -0
- package/dist/types/program/ops/opCalculation/index.d.ts +11 -0
- package/dist/types/program/ops/opCalculation/opmAddition.d.ts +11 -0
- package/dist/types/program/ops/opCalculation/opmDivision.d.ts +11 -0
- package/dist/types/program/ops/opCalculation/opmMultiplication.d.ts +11 -0
- package/dist/types/program/ops/opCalculation/opmRemainder.d.ts +11 -0
- package/dist/types/program/ops/opCalculation/opmSubtraction.d.ts +11 -0
- package/dist/types/program/ops/opComparison/index.d.ts +11 -0
- package/dist/types/program/ops/opComparison/opcEqual.d.ts +11 -0
- package/dist/types/program/ops/opComparison/opcGreater.d.ts +11 -0
- package/dist/types/program/ops/opComparison/opcGreaterEqual.d.ts +11 -0
- package/dist/types/program/ops/opComparison/opcLess.d.ts +11 -0
- package/dist/types/program/ops/opComparison/opcLessEqual.d.ts +11 -0
- package/dist/types/program/ops/opComparison/opcUnequal.d.ts +11 -0
- package/dist/types/program/ops/opConstant.d.ts +11 -0
- package/dist/types/program/ops/opConstantFalse.d.ts +11 -0
- package/dist/types/program/ops/opConstantNull.d.ts +11 -0
- package/dist/types/program/ops/opConstantTrue.d.ts +11 -0
- package/dist/types/program/ops/opFunctionDefinition.d.ts +11 -0
- package/dist/types/program/ops/opIf.d.ts +11 -0
- package/dist/types/program/ops/opInterpolatedString.d.ts +11 -0
- package/dist/types/program/ops/opNegation.d.ts +11 -0
- package/dist/types/program/ops/opNot.d.ts +11 -0
- package/dist/types/program/ops/opNullCoalescence.d.ts +11 -0
- package/dist/types/program/ops/opNumber.d.ts +11 -0
- package/dist/types/program/ops/opObjectConstructor.d.ts +11 -0
- package/dist/types/program/ops/opOr.d.ts +11 -0
- package/dist/types/program/ops/opOutputConcat.d.ts +11 -0
- package/dist/types/program/ops/opString.d.ts +11 -0
- package/dist/types/program/ops/opTry.d.ts +11 -0
- package/dist/types/program/ops/opVariable.d.ts +11 -0
- package/dist/types/program/ops/opVariableDefinition.d.ts +11 -0
- package/dist/types/program/ops/opVoid.d.ts +11 -0
- package/dist/types/program/ops/utils.d.ts +5 -0
- package/dist/types/program/params.d.ts +68 -0
- package/dist/types/runtime/index.d.ts +83 -0
- package/package.json +66 -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 -31
- package/lib/program/ops/opAccess/opaSlice.js +0 -44
- 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 -69
- package/lib/program/ops/opAssignment/opaAssignSlice.js +0 -99
- 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 -31
- package/src/program/ops/opAccess/opaSlice.js +0 -58
- 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 -74
- package/src/program/ops/opAssignment/opaAssignSlice.js +0 -157
- 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
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.JPLZeroDivisionError = exports.JPLTypeError = exports.JPLTypeConversionError = exports.JPLReferenceError = void 0;
|
|
7
|
-
var _types = require("../types");
|
|
8
|
-
var _execution = _interopRequireDefault(require("./execution"));
|
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
-
function format(value, replacements) {
|
|
11
|
-
return replacements.length > 0 ? (0, _types.template)(value, ...replacements) : (0, _types.displayValue)(value);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* JPL error type for generic runtime errors.
|
|
16
|
-
*
|
|
17
|
-
* `value` can by of any type.
|
|
18
|
-
* If at least one replacement is specified, the value is formatted as a template.
|
|
19
|
-
*/
|
|
20
|
-
class JPLRuntimeError extends _execution.default {
|
|
21
|
-
constructor(value, ...replacements) {
|
|
22
|
-
const message = format(value, replacements);
|
|
23
|
-
super(message, 'JPLRuntimeError');
|
|
24
|
-
this.value = replacements.length > 0 ? message : (0, _types.normalize)(value);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
var _default = exports.default = JPLRuntimeError;
|
|
28
|
-
/**
|
|
29
|
-
* JPL runtime error type for type errors.
|
|
30
|
-
*
|
|
31
|
-
* `value` can by of any type.
|
|
32
|
-
* If at least one replacement is specified, the value is formatted as a template.
|
|
33
|
-
*/
|
|
34
|
-
class JPLTypeError extends JPLRuntimeError {
|
|
35
|
-
constructor(value, ...replacements) {
|
|
36
|
-
super(`TypeError - ${format(value, replacements)}`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* JPL runtime error type for reference errors.
|
|
42
|
-
*
|
|
43
|
-
* `value` can by of any type.
|
|
44
|
-
* If at least one replacement is specified, the value is formatted as a template.
|
|
45
|
-
*/
|
|
46
|
-
exports.JPLTypeError = JPLTypeError;
|
|
47
|
-
class JPLReferenceError extends JPLRuntimeError {
|
|
48
|
-
constructor(value, ...replacements) {
|
|
49
|
-
super(`ReferenceError - ${format(value, replacements)}`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* JPL runtime error type for zero division errors.
|
|
55
|
-
*
|
|
56
|
-
* `value` can by of any type.
|
|
57
|
-
* If at least one replacement is specified, the value is formatted as a template.
|
|
58
|
-
*/
|
|
59
|
-
exports.JPLReferenceError = JPLReferenceError;
|
|
60
|
-
class JPLZeroDivisionError extends JPLRuntimeError {
|
|
61
|
-
constructor(value, ...replacements) {
|
|
62
|
-
super(`ZeroDivisionError - ${format(value, replacements)}`);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* JPL runtime error type for type conversion errors.
|
|
68
|
-
*
|
|
69
|
-
* `value` can by of any type.
|
|
70
|
-
* If at least one replacement is specified, the value is formatted as a template.
|
|
71
|
-
*/
|
|
72
|
-
exports.JPLZeroDivisionError = JPLZeroDivisionError;
|
|
73
|
-
class JPLTypeConversionError extends JPLRuntimeError {
|
|
74
|
-
constructor(value, ...replacements) {
|
|
75
|
-
super(`TypeConversionError - ${format(value, replacements)}`);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
exports.JPLTypeConversionError = JPLTypeConversionError;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _error = _interopRequireDefault(require("./error"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
/** JPL error type for syntax errors */
|
|
10
|
-
class JPLSyntaxError extends _error.default {
|
|
11
|
-
constructor(message, src = '', at = 0) {
|
|
12
|
-
super(message, 'JPLSyntaxError');
|
|
13
|
-
this.src = src;
|
|
14
|
-
this.at = at;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
var _default = exports.default = JPLSyntaxError;
|
package/lib/library/functions.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.nativeFunction = nativeFunction;
|
|
7
|
-
exports.orphanFunction = orphanFunction;
|
|
8
|
-
exports.scopedFunction = scopedFunction;
|
|
9
|
-
var _runtimeScope = _interopRequireDefault(require("./runtimeScope"));
|
|
10
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
function jplEnclosure(runtime, signal, next, input, ...args) {
|
|
12
|
-
const {
|
|
13
|
-
argNames,
|
|
14
|
-
pipe,
|
|
15
|
-
scope
|
|
16
|
-
} = this;
|
|
17
|
-
return runtime.executeInstructions(pipe, [input], scope.next({
|
|
18
|
-
signal,
|
|
19
|
-
vars: Object.fromEntries(argNames.map((name, i) => [name, args[i] ?? null]))
|
|
20
|
-
}), next);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Create a scoped JPL function from the specified instructions.
|
|
25
|
-
*
|
|
26
|
-
* The function is bound to the specified scope.
|
|
27
|
-
*
|
|
28
|
-
* @param {string[]} argNames Names to bind the function arguments to
|
|
29
|
-
* @param {object[]} instructions Instructions to execute
|
|
30
|
-
* @param {JPLRuntimeScope} scope Runtime scope to bind the function to
|
|
31
|
-
*/
|
|
32
|
-
function scopedFunction(argNames, instructions, scope) {
|
|
33
|
-
return jplEnclosure.bind({
|
|
34
|
-
argNames,
|
|
35
|
-
pipe: instructions,
|
|
36
|
-
scope
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Create an orphan JPL function from the specified instructions.
|
|
42
|
-
*
|
|
43
|
-
* Some optional scope presets may be specified, e.g. for allowing the function access to some specified variables.
|
|
44
|
-
* Other than that, the function does not have access to any external variables.
|
|
45
|
-
*
|
|
46
|
-
* @param {string[]} argNames Names to bind the function arguments to
|
|
47
|
-
* @param {object[]} instructions Instructions to execute
|
|
48
|
-
* @param {{ vars: object? }} [presets] Optional scope presets
|
|
49
|
-
*/
|
|
50
|
-
function orphanFunction(argNames, instructions, presets) {
|
|
51
|
-
return scopedFunction(argNames, instructions, new _runtimeScope.default(presets));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Wrap the specified synchronous function to allow it to be used as a JPL function.
|
|
56
|
-
*
|
|
57
|
-
* If your function runs asynchronous routines, you should create the function yourself.
|
|
58
|
-
* `next` must be called for each single result, which produces an array of results itself.
|
|
59
|
-
* All resulting results must be returned as a single array.
|
|
60
|
-
*
|
|
61
|
-
* It is recommended to check the provided JPLRuntimeSignal in asynchronous routines to stop the routine when execution has been canceled:
|
|
62
|
-
* ```
|
|
63
|
-
* signal.checkHealth();
|
|
64
|
-
* ```
|
|
65
|
-
*
|
|
66
|
-
* The following pattern can be used to merge the results of multiple asynchronous routines:
|
|
67
|
-
* ```
|
|
68
|
-
* const promises = ...;
|
|
69
|
-
* return runtime.muxAll([promises], async (promise) => {
|
|
70
|
-
* const result = await promise;
|
|
71
|
-
* return next(result);
|
|
72
|
-
* });
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
|
-
* @param {(runtime: JPLRuntime, input: any, ...args: any[]) => (Promise<any[]> | any[])} fn The function to be wrapped
|
|
76
|
-
*/
|
|
77
|
-
function nativeFunction(fn) {
|
|
78
|
-
return async (runtime, signal, next, input, ...args) => {
|
|
79
|
-
const results = await fn(runtime, input, ...args);
|
|
80
|
-
return runtime.muxAll([results], next);
|
|
81
|
-
};
|
|
82
|
-
}
|
package/lib/library/index.js
DELETED
|
@@ -1,335 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _exportNames = {
|
|
7
|
-
applyArray: true,
|
|
8
|
-
applyCombinations: true,
|
|
9
|
-
applyObject: true,
|
|
10
|
-
DEFINITION_VERSION: true,
|
|
11
|
-
DEFINITION_VERSION_MAJOR: true,
|
|
12
|
-
DEFINITION_VERSION_MINOR: true,
|
|
13
|
-
adaptError: true,
|
|
14
|
-
adaptErrors: true,
|
|
15
|
-
adaptErrorsAsync: true,
|
|
16
|
-
JPLErrorEnclosure: true,
|
|
17
|
-
JPLError: true,
|
|
18
|
-
JPLExecutionError: true,
|
|
19
|
-
JPLFatalError: true,
|
|
20
|
-
JPLReferenceError: true,
|
|
21
|
-
JPLRuntimeError: true,
|
|
22
|
-
JPLTypeConversionError: true,
|
|
23
|
-
JPLTypeError: true,
|
|
24
|
-
JPLZeroDivisionError: true,
|
|
25
|
-
JPLSyntaxError: true,
|
|
26
|
-
nativeFunction: true,
|
|
27
|
-
orphanFunction: true,
|
|
28
|
-
scopedFunction: true,
|
|
29
|
-
mux: true,
|
|
30
|
-
muxAll: true,
|
|
31
|
-
muxAsync: true,
|
|
32
|
-
muxOne: true,
|
|
33
|
-
JPLRuntimeScope: true,
|
|
34
|
-
JPLType: true,
|
|
35
|
-
assertType: true,
|
|
36
|
-
displayValue: true,
|
|
37
|
-
jplJSONStripper: true,
|
|
38
|
-
jplStripper: true,
|
|
39
|
-
jplTypedStripper: true,
|
|
40
|
-
jsonStripper: true,
|
|
41
|
-
normalize: true,
|
|
42
|
-
rawStripper: true,
|
|
43
|
-
strictDisplayValue: true,
|
|
44
|
-
stringify: true,
|
|
45
|
-
strip: true,
|
|
46
|
-
template: true,
|
|
47
|
-
typeOf: true,
|
|
48
|
-
typeOrder: true,
|
|
49
|
-
unwrap: true
|
|
50
|
-
};
|
|
51
|
-
Object.defineProperty(exports, "DEFINITION_VERSION", {
|
|
52
|
-
enumerable: true,
|
|
53
|
-
get: function () {
|
|
54
|
-
return _definition.DEFINITION_VERSION;
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
Object.defineProperty(exports, "DEFINITION_VERSION_MAJOR", {
|
|
58
|
-
enumerable: true,
|
|
59
|
-
get: function () {
|
|
60
|
-
return _definition.DEFINITION_VERSION_MAJOR;
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
Object.defineProperty(exports, "DEFINITION_VERSION_MINOR", {
|
|
64
|
-
enumerable: true,
|
|
65
|
-
get: function () {
|
|
66
|
-
return _definition.DEFINITION_VERSION_MINOR;
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
Object.defineProperty(exports, "JPLError", {
|
|
70
|
-
enumerable: true,
|
|
71
|
-
get: function () {
|
|
72
|
-
return _error.default;
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
Object.defineProperty(exports, "JPLErrorEnclosure", {
|
|
76
|
-
enumerable: true,
|
|
77
|
-
get: function () {
|
|
78
|
-
return _enclosure.default;
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
Object.defineProperty(exports, "JPLExecutionError", {
|
|
82
|
-
enumerable: true,
|
|
83
|
-
get: function () {
|
|
84
|
-
return _execution.default;
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
Object.defineProperty(exports, "JPLFatalError", {
|
|
88
|
-
enumerable: true,
|
|
89
|
-
get: function () {
|
|
90
|
-
return _fatal.default;
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
Object.defineProperty(exports, "JPLReferenceError", {
|
|
94
|
-
enumerable: true,
|
|
95
|
-
get: function () {
|
|
96
|
-
return _runtime.JPLReferenceError;
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
Object.defineProperty(exports, "JPLRuntimeError", {
|
|
100
|
-
enumerable: true,
|
|
101
|
-
get: function () {
|
|
102
|
-
return _runtime.default;
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
Object.defineProperty(exports, "JPLRuntimeScope", {
|
|
106
|
-
enumerable: true,
|
|
107
|
-
get: function () {
|
|
108
|
-
return _runtimeScope.default;
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
Object.defineProperty(exports, "JPLSyntaxError", {
|
|
112
|
-
enumerable: true,
|
|
113
|
-
get: function () {
|
|
114
|
-
return _syntax.default;
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
Object.defineProperty(exports, "JPLType", {
|
|
118
|
-
enumerable: true,
|
|
119
|
-
get: function () {
|
|
120
|
-
return _types.JPLType;
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
Object.defineProperty(exports, "JPLTypeConversionError", {
|
|
124
|
-
enumerable: true,
|
|
125
|
-
get: function () {
|
|
126
|
-
return _runtime.JPLTypeConversionError;
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
Object.defineProperty(exports, "JPLTypeError", {
|
|
130
|
-
enumerable: true,
|
|
131
|
-
get: function () {
|
|
132
|
-
return _runtime.JPLTypeError;
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
Object.defineProperty(exports, "JPLZeroDivisionError", {
|
|
136
|
-
enumerable: true,
|
|
137
|
-
get: function () {
|
|
138
|
-
return _runtime.JPLZeroDivisionError;
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
Object.defineProperty(exports, "adaptError", {
|
|
142
|
-
enumerable: true,
|
|
143
|
-
get: function () {
|
|
144
|
-
return _adaptErrors.adaptError;
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
Object.defineProperty(exports, "adaptErrors", {
|
|
148
|
-
enumerable: true,
|
|
149
|
-
get: function () {
|
|
150
|
-
return _adaptErrors.default;
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
Object.defineProperty(exports, "adaptErrorsAsync", {
|
|
154
|
-
enumerable: true,
|
|
155
|
-
get: function () {
|
|
156
|
-
return _adaptErrors.adaptErrorsAsync;
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
Object.defineProperty(exports, "applyArray", {
|
|
160
|
-
enumerable: true,
|
|
161
|
-
get: function () {
|
|
162
|
-
return _apply.applyArray;
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
Object.defineProperty(exports, "applyCombinations", {
|
|
166
|
-
enumerable: true,
|
|
167
|
-
get: function () {
|
|
168
|
-
return _apply.applyCombinations;
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
Object.defineProperty(exports, "applyObject", {
|
|
172
|
-
enumerable: true,
|
|
173
|
-
get: function () {
|
|
174
|
-
return _apply.applyObject;
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
Object.defineProperty(exports, "assertType", {
|
|
178
|
-
enumerable: true,
|
|
179
|
-
get: function () {
|
|
180
|
-
return _types.assertType;
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
Object.defineProperty(exports, "displayValue", {
|
|
184
|
-
enumerable: true,
|
|
185
|
-
get: function () {
|
|
186
|
-
return _types.displayValue;
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
Object.defineProperty(exports, "jplJSONStripper", {
|
|
190
|
-
enumerable: true,
|
|
191
|
-
get: function () {
|
|
192
|
-
return _types.jplJSONStripper;
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
Object.defineProperty(exports, "jplStripper", {
|
|
196
|
-
enumerable: true,
|
|
197
|
-
get: function () {
|
|
198
|
-
return _types.jplStripper;
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
Object.defineProperty(exports, "jplTypedStripper", {
|
|
202
|
-
enumerable: true,
|
|
203
|
-
get: function () {
|
|
204
|
-
return _types.jplTypedStripper;
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
Object.defineProperty(exports, "jsonStripper", {
|
|
208
|
-
enumerable: true,
|
|
209
|
-
get: function () {
|
|
210
|
-
return _types.jsonStripper;
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
Object.defineProperty(exports, "mux", {
|
|
214
|
-
enumerable: true,
|
|
215
|
-
get: function () {
|
|
216
|
-
return _mux.default;
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
Object.defineProperty(exports, "muxAll", {
|
|
220
|
-
enumerable: true,
|
|
221
|
-
get: function () {
|
|
222
|
-
return _mux.muxAll;
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
Object.defineProperty(exports, "muxAsync", {
|
|
226
|
-
enumerable: true,
|
|
227
|
-
get: function () {
|
|
228
|
-
return _mux.muxAsync;
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
Object.defineProperty(exports, "muxOne", {
|
|
232
|
-
enumerable: true,
|
|
233
|
-
get: function () {
|
|
234
|
-
return _mux.muxOne;
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
Object.defineProperty(exports, "nativeFunction", {
|
|
238
|
-
enumerable: true,
|
|
239
|
-
get: function () {
|
|
240
|
-
return _functions.nativeFunction;
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
Object.defineProperty(exports, "normalize", {
|
|
244
|
-
enumerable: true,
|
|
245
|
-
get: function () {
|
|
246
|
-
return _types.normalize;
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
Object.defineProperty(exports, "orphanFunction", {
|
|
250
|
-
enumerable: true,
|
|
251
|
-
get: function () {
|
|
252
|
-
return _functions.orphanFunction;
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
Object.defineProperty(exports, "rawStripper", {
|
|
256
|
-
enumerable: true,
|
|
257
|
-
get: function () {
|
|
258
|
-
return _types.rawStripper;
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
Object.defineProperty(exports, "scopedFunction", {
|
|
262
|
-
enumerable: true,
|
|
263
|
-
get: function () {
|
|
264
|
-
return _functions.scopedFunction;
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
Object.defineProperty(exports, "strictDisplayValue", {
|
|
268
|
-
enumerable: true,
|
|
269
|
-
get: function () {
|
|
270
|
-
return _types.strictDisplayValue;
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
Object.defineProperty(exports, "stringify", {
|
|
274
|
-
enumerable: true,
|
|
275
|
-
get: function () {
|
|
276
|
-
return _types.stringify;
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
Object.defineProperty(exports, "strip", {
|
|
280
|
-
enumerable: true,
|
|
281
|
-
get: function () {
|
|
282
|
-
return _types.strip;
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
Object.defineProperty(exports, "template", {
|
|
286
|
-
enumerable: true,
|
|
287
|
-
get: function () {
|
|
288
|
-
return _types.template;
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
Object.defineProperty(exports, "typeOf", {
|
|
292
|
-
enumerable: true,
|
|
293
|
-
get: function () {
|
|
294
|
-
return _types.typeOf;
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
Object.defineProperty(exports, "typeOrder", {
|
|
298
|
-
enumerable: true,
|
|
299
|
-
get: function () {
|
|
300
|
-
return _types.typeOrder;
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
Object.defineProperty(exports, "unwrap", {
|
|
304
|
-
enumerable: true,
|
|
305
|
-
get: function () {
|
|
306
|
-
return _types.unwrap;
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
var _apply = require("./apply");
|
|
310
|
-
var _definition = require("./definition");
|
|
311
|
-
var _adaptErrors = _interopRequireWildcard(require("./errors/adaptErrors"));
|
|
312
|
-
var _enclosure = _interopRequireDefault(require("./errors/enclosure"));
|
|
313
|
-
var _error = _interopRequireDefault(require("./errors/error"));
|
|
314
|
-
var _execution = _interopRequireDefault(require("./errors/execution"));
|
|
315
|
-
var _fatal = _interopRequireDefault(require("./errors/fatal"));
|
|
316
|
-
var _runtime = _interopRequireWildcard(require("./errors/runtime"));
|
|
317
|
-
var _syntax = _interopRequireDefault(require("./errors/syntax"));
|
|
318
|
-
var _functions = require("./functions");
|
|
319
|
-
var _mux = _interopRequireWildcard(require("./mux"));
|
|
320
|
-
var _ops = require("./ops");
|
|
321
|
-
Object.keys(_ops).forEach(function (key) {
|
|
322
|
-
if (key === "default" || key === "__esModule") return;
|
|
323
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
324
|
-
if (key in exports && exports[key] === _ops[key]) return;
|
|
325
|
-
Object.defineProperty(exports, key, {
|
|
326
|
-
enumerable: true,
|
|
327
|
-
get: function () {
|
|
328
|
-
return _ops[key];
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
});
|
|
332
|
-
var _runtimeScope = _interopRequireDefault(require("./runtimeScope"));
|
|
333
|
-
var _types = require("./types");
|
|
334
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
335
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
package/lib/library/mux.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
exports.mergeSegments = mergeSegments;
|
|
8
|
-
exports.muxAll = muxAll;
|
|
9
|
-
exports.muxAsync = muxAsync;
|
|
10
|
-
exports.muxOne = muxOne;
|
|
11
|
-
/**
|
|
12
|
-
* Multiplex the specified array of arguments by calling cb for all possible combinations of arguments.
|
|
13
|
-
* If the specified `args` array is empty, `cb` is called once without any arguments.
|
|
14
|
-
*
|
|
15
|
-
* `mux([[1, 2], [3, 4]], cb)` for example calls:
|
|
16
|
-
* - `cb(1, 3)`
|
|
17
|
-
* - `cb(1, 4)`
|
|
18
|
-
* - `cb(2, 3)`
|
|
19
|
-
* - `cb(2, 4)`
|
|
20
|
-
*/
|
|
21
|
-
function mux(args, cb) {
|
|
22
|
-
const argCount = args.length;
|
|
23
|
-
if (argCount === 1) {
|
|
24
|
-
args[0].forEach(arg => cb(arg));
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
let execCount = 1;
|
|
28
|
-
const indices = args.map(arg => {
|
|
29
|
-
const argLength = arg?.length ?? 0;
|
|
30
|
-
execCount *= argLength;
|
|
31
|
-
return [argLength, 0, arg];
|
|
32
|
-
});
|
|
33
|
-
if (execCount === 0) return;
|
|
34
|
-
const buffer = args.map(([v]) => v);
|
|
35
|
-
let execIndex = 0;
|
|
36
|
-
for (;;) {
|
|
37
|
-
cb(...buffer);
|
|
38
|
-
execIndex += 1;
|
|
39
|
-
if (execIndex >= execCount) break;
|
|
40
|
-
// determine next combination
|
|
41
|
-
for (let argIndex = argCount - 1; argIndex >= 0; argIndex -= 1) {
|
|
42
|
-
const arg = indices[argIndex];
|
|
43
|
-
const [max, current, values] = arg;
|
|
44
|
-
const next = current + 1;
|
|
45
|
-
if (next < max) {
|
|
46
|
-
arg[1] = next;
|
|
47
|
-
buffer[argIndex] = values[next];
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
arg[1] = 0;
|
|
51
|
-
[buffer[argIndex]] = values;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
var _default = exports.default = mux;
|
|
56
|
-
/** Multiplex the specified array of arguments and return the results produced by the callbacks */
|
|
57
|
-
function muxOne(args, cb) {
|
|
58
|
-
const argCount = args.length;
|
|
59
|
-
if (argCount === 1) return args[0].map(arg => cb(arg));
|
|
60
|
-
let execCount = 1;
|
|
61
|
-
const indices = args.map(arg => {
|
|
62
|
-
const argLength = arg?.length ?? 0;
|
|
63
|
-
execCount *= argLength;
|
|
64
|
-
return [argLength, 0, arg];
|
|
65
|
-
});
|
|
66
|
-
if (execCount === 0) return [];
|
|
67
|
-
const outputs = new Array(execCount);
|
|
68
|
-
const buffer = args.map(([v]) => v);
|
|
69
|
-
let execIndex = 0;
|
|
70
|
-
for (;;) {
|
|
71
|
-
outputs[execIndex] = cb(...buffer);
|
|
72
|
-
execIndex += 1;
|
|
73
|
-
if (execIndex >= execCount) break;
|
|
74
|
-
// determine next combination
|
|
75
|
-
for (let argIndex = argCount - 1; argIndex >= 0; argIndex -= 1) {
|
|
76
|
-
const arg = indices[argIndex];
|
|
77
|
-
const [max, current, values] = arg;
|
|
78
|
-
const next = current + 1;
|
|
79
|
-
if (next < max) {
|
|
80
|
-
arg[1] = next;
|
|
81
|
-
buffer[argIndex] = values[next];
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
arg[1] = 0;
|
|
85
|
-
[buffer[argIndex]] = values;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return outputs;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/** Multiplex the specified array of arguments asynchronously and return the results produced by the callbacks */
|
|
92
|
-
function muxAsync(args, cb) {
|
|
93
|
-
return Promise.all(muxOne(args, cb));
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/** Multiplex the specified array of arguments asynchronously and return a single array of all merged result arrays produced by the callbacks */
|
|
97
|
-
async function muxAll(args, cb) {
|
|
98
|
-
return mergeSegments(await muxAsync(args, cb));
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/** Create a single array from the specified array segments */
|
|
102
|
-
function mergeSegments(segments) {
|
|
103
|
-
if (segments.length === 0) return segments;
|
|
104
|
-
if (segments.length === 1) return segments[0];
|
|
105
|
-
return segments.flat(1);
|
|
106
|
-
}
|
package/lib/library/ops/index.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _op = require("./op");
|
|
7
|
-
Object.keys(_op).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _op[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _op[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _opa = require("./opa");
|
|
18
|
-
Object.keys(_opa).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _opa[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _opa[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _opc = require("./opc");
|
|
29
|
-
Object.keys(_opc).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _opc[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _opc[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _opm = require("./opm");
|
|
40
|
-
Object.keys(_opm).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] === _opm[key]) return;
|
|
43
|
-
Object.defineProperty(exports, key, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _opm[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
var _opu = require("./opu");
|
|
51
|
-
Object.keys(_opu).forEach(function (key) {
|
|
52
|
-
if (key === "default" || key === "__esModule") return;
|
|
53
|
-
if (key in exports && exports[key] === _opu[key]) return;
|
|
54
|
-
Object.defineProperty(exports, key, {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function () {
|
|
57
|
-
return _opu[key];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|