greybel-interpreter 4.6.5 → 4.6.6
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/types/function.d.ts +11 -1
- package/dist/types/function.js +38 -3
- package/package.json +56 -56
package/dist/types/function.d.ts
CHANGED
|
@@ -4,10 +4,15 @@ import { ContextTypeIntrinsics } from '../context/types';
|
|
|
4
4
|
import { ObjectValue } from '../utils/object-value';
|
|
5
5
|
import type { VM } from '../vm';
|
|
6
6
|
import { CustomValue } from './base';
|
|
7
|
+
import { CustomValueWithIntrinsics, CustomValueWithIntrinsicsResult } from './with-intrinsics';
|
|
8
|
+
export declare class CustomFunctionIterator implements Iterator<CustomValue> {
|
|
9
|
+
index: number;
|
|
10
|
+
next(): IteratorResult<CustomValue>;
|
|
11
|
+
}
|
|
7
12
|
export interface CustomFunctionCallback {
|
|
8
13
|
(vm: VM, self: CustomValue, args: Map<string, CustomValue>): Promise<NonNullable<CustomValue>>;
|
|
9
14
|
}
|
|
10
|
-
export declare class CustomFunction extends
|
|
15
|
+
export declare class CustomFunction extends CustomValueWithIntrinsics {
|
|
11
16
|
static readonly intrinsics: ObjectValue;
|
|
12
17
|
static createExternal(name: string, callback: CustomFunctionCallback): CustomFunction;
|
|
13
18
|
static createExternalWithSelf(name: string, callback: CustomFunctionCallback): CustomFunction;
|
|
@@ -20,6 +25,7 @@ export declare class CustomFunction extends CustomValue {
|
|
|
20
25
|
addArgument(name: string, defaultValue?: CustomValue): CustomFunction;
|
|
21
26
|
fork(): CustomFunction;
|
|
22
27
|
forkAs(name: string): CustomFunction;
|
|
28
|
+
[Symbol.iterator](): CustomFunctionIterator;
|
|
23
29
|
getCustomType(): string;
|
|
24
30
|
toNumber(): number;
|
|
25
31
|
toInt(): number;
|
|
@@ -27,5 +33,9 @@ export declare class CustomFunction extends CustomValue {
|
|
|
27
33
|
toString(): string;
|
|
28
34
|
toTruthy(): boolean;
|
|
29
35
|
instanceOf(v: CustomValue, typeIntrinsics: ContextTypeIntrinsics): boolean;
|
|
36
|
+
has(): boolean;
|
|
37
|
+
set(_path: CustomValue, _newValue: CustomValue): void;
|
|
38
|
+
get(current: CustomValue, typeIntrinsics: ContextTypeIntrinsics): CustomValue;
|
|
39
|
+
getWithOrigin(current: CustomValue, typeIntrinsics: ContextTypeIntrinsics): CustomValueWithIntrinsicsResult;
|
|
30
40
|
hash(): number;
|
|
31
41
|
}
|
package/dist/types/function.js
CHANGED
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CustomFunction = void 0;
|
|
3
|
+
exports.CustomFunction = exports.CustomFunctionIterator = void 0;
|
|
4
4
|
const instruction_1 = require("../bytecode-generator/instruction");
|
|
5
5
|
const keywords_1 = require("../bytecode-generator/keywords");
|
|
6
6
|
const hash_1 = require("../utils/hash");
|
|
7
7
|
const object_value_1 = require("../utils/object-value");
|
|
8
8
|
const uuid_1 = require("../utils/uuid");
|
|
9
|
-
const base_1 = require("./base");
|
|
10
9
|
const default_1 = require("./default");
|
|
11
10
|
const nil_1 = require("./nil");
|
|
12
11
|
const string_1 = require("./string");
|
|
13
|
-
|
|
12
|
+
const with_intrinsics_1 = require("./with-intrinsics");
|
|
13
|
+
class CustomFunctionIterator {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.index = 0;
|
|
16
|
+
}
|
|
17
|
+
next() {
|
|
18
|
+
return {
|
|
19
|
+
value: null,
|
|
20
|
+
done: true
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.CustomFunctionIterator = CustomFunctionIterator;
|
|
25
|
+
class CustomFunction extends with_intrinsics_1.CustomValueWithIntrinsics {
|
|
14
26
|
static createExternal(name, callback) {
|
|
15
27
|
const args = [];
|
|
16
28
|
return new CustomFunction(name, [
|
|
@@ -62,6 +74,9 @@ class CustomFunction extends base_1.CustomValue {
|
|
|
62
74
|
forkAs(name) {
|
|
63
75
|
return new CustomFunction(name, this.value, this.arguments, this.outer);
|
|
64
76
|
}
|
|
77
|
+
[Symbol.iterator]() {
|
|
78
|
+
return new CustomFunctionIterator();
|
|
79
|
+
}
|
|
65
80
|
getCustomType() {
|
|
66
81
|
return 'function';
|
|
67
82
|
}
|
|
@@ -94,6 +109,26 @@ class CustomFunction extends base_1.CustomValue {
|
|
|
94
109
|
var _a;
|
|
95
110
|
return v.value === ((_a = typeIntrinsics.function) !== null && _a !== void 0 ? _a : CustomFunction.intrinsics);
|
|
96
111
|
}
|
|
112
|
+
has() {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
set(_path, _newValue) {
|
|
116
|
+
throw new Error('Mutable operations are not allowed on a function.');
|
|
117
|
+
}
|
|
118
|
+
get(current, typeIntrinsics) {
|
|
119
|
+
var _a;
|
|
120
|
+
const intrinsics = (_a = typeIntrinsics.function) !== null && _a !== void 0 ? _a : CustomFunction.getIntrinsics();
|
|
121
|
+
if (intrinsics.has(current)) {
|
|
122
|
+
return intrinsics.get(current);
|
|
123
|
+
}
|
|
124
|
+
throw new Error(`Unknown path in string ${current.toString()}.`);
|
|
125
|
+
}
|
|
126
|
+
getWithOrigin(current, typeIntrinsics) {
|
|
127
|
+
return {
|
|
128
|
+
value: this.get(current, typeIntrinsics),
|
|
129
|
+
origin: null
|
|
130
|
+
};
|
|
131
|
+
}
|
|
97
132
|
hash() {
|
|
98
133
|
return (0, hash_1.getStringHashCode)(this.toString());
|
|
99
134
|
}
|
package/package.json
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
2
|
+
"name": "greybel-interpreter",
|
|
3
|
+
"version": "4.6.6",
|
|
4
|
+
"description": "Interpreter",
|
|
5
|
+
"main": "dist/index",
|
|
6
|
+
"typings": "dist/index",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"prepublishOnly": "npm run build",
|
|
9
|
+
"build": "npm run clean && tsc -p .",
|
|
10
|
+
"watch": "tsc -w -p .",
|
|
11
|
+
"clean": "rm -rf dist",
|
|
12
|
+
"test": "jest ./tests --testTimeout 10000",
|
|
13
|
+
"lint": "eslint ./src/**/*.ts",
|
|
14
|
+
"lint:fix": "eslint --fix ./src/**/*.ts"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/ayecue/greybel-interpreter.git"
|
|
19
|
+
},
|
|
20
|
+
"author": {
|
|
21
|
+
"name": "ayecue",
|
|
22
|
+
"email": "soerenwehmeier@googlemail.com"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/ayecue/greybel-interpreter/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/ayecue/greybel-interpreter#readme",
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/jest": "^27.0.3",
|
|
31
|
+
"@types/node": "^17.0.0",
|
|
32
|
+
"@types/uuid": "^8.3.3",
|
|
33
|
+
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
34
|
+
"@typescript-eslint/parser": "^5.62.0",
|
|
35
|
+
"eslint": "^8.17.0",
|
|
36
|
+
"eslint-config-prettier": "^8.5.0",
|
|
37
|
+
"eslint-config-standard": "^17.0.0",
|
|
38
|
+
"eslint-plugin-import": "^2.26.0",
|
|
39
|
+
"eslint-plugin-jest": "^26.5.3",
|
|
40
|
+
"eslint-plugin-node": "^11.1.0",
|
|
41
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
42
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
43
|
+
"eslint-plugin-security": "^1.5.0",
|
|
44
|
+
"eslint-plugin-simple-import-sort": "^7.0.0",
|
|
45
|
+
"jest": "^27.4.5",
|
|
46
|
+
"nodemon": "^2.0.15",
|
|
47
|
+
"ts-node": "^10.4.0",
|
|
48
|
+
"typescript": "^5.0.4"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"greybel-core": "~1.6.1",
|
|
52
|
+
"hyperid": "^3.2.0"
|
|
53
|
+
},
|
|
54
|
+
"keywords": [
|
|
55
|
+
"miniscript"
|
|
56
|
+
]
|
|
57
|
+
}
|