greybel-interpreter 3.4.2 → 3.4.4
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/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/operations/evaluate.d.ts +1 -2
- package/dist/operations/evaluate.js +20 -2
- package/dist/types/base.d.ts +1 -0
- package/dist/types/function.d.ts +1 -0
- package/dist/types/function.js +2 -0
- package/dist/types/list.d.ts +2 -0
- package/dist/types/list.js +6 -1
- package/dist/types/map.d.ts +2 -0
- package/dist/types/map.js +6 -1
- package/dist/types/nil.d.ts +1 -0
- package/dist/types/nil.js +1 -0
- package/dist/types/number.d.ts +1 -0
- package/dist/types/number.js +1 -0
- package/dist/types/string.d.ts +1 -0
- package/dist/types/string.js +1 -0
- package/dist/types/with-intrinsics.d.ts +1 -0
- package/dist/utils/deep-equal.d.ts +2 -1
- package/dist/utils/deep-equal.js +35 -30
- package/dist/utils/deep-hash.d.ts +2 -0
- package/dist/utils/deep-hash.js +44 -0
- package/dist/utils/object-value.js +5 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Not = exports.Noop = exports.NewInstance = exports.NegatedBinary = exports.MapOperation = exports.Literal = exports.List = exports.Include = exports.Import = exports.IfStatement = exports.Clause = exports.FunctionOperation = exports.For = exports.StringProcessorHandler = exports.NumberProcessorHandler = exports.MapProcessorHandler = exports.ListProcessorHandler = exports.handleString = exports.handleNumber = exports.handleMap = exports.handleList = exports.handle = exports.GenericProcessorHandler = exports.Evaluate = exports.DebuggerStatement = exports.Continue = exports.Chunk = exports.Call = exports.Break = exports.Block = exports.Assign = exports.Interpreter = exports.HandlerContainer = exports.ResourceHandler = exports.DefaultResourceHandler = exports.OutputHandler = exports.DefaultOutputHandler = exports.ErrorHandler = exports.DefaultErrorHandler = exports.defaultCPSVisit = exports.CPSContext = exports.CPS = exports.Scope = exports.ProcessState = exports.OperationContext = exports.LoopState = exports.FunctionState = exports.Debugger = exports.ContextType = exports.ContextState = void 0;
|
|
4
|
-
exports.deepEqual = exports.Path = exports.ObjectValue = exports.RuntimeError = exports.PrepareError = exports.CustomValueWithIntrinsics = exports.CustomObject = exports.CustomStringIterator = exports.CustomString = exports.CustomNumber = exports.CustomNil = exports.CustomMapIterator = exports.CustomMap = exports.CustomListIterator = exports.CustomList = exports.CustomFunction = exports.Argument = exports.DefaultType = exports.CustomBoolean = exports.CustomValue = exports.While = exports.Return = exports.ResolveResult = exports.Resolve = exports.OperationSegment = exports.IndexSegment = exports.IdentifierSegment = exports.Reference = exports.Operation = void 0;
|
|
4
|
+
exports.deepHash = exports.deepEqual = exports.Path = exports.ObjectValue = exports.RuntimeError = exports.PrepareError = exports.CustomValueWithIntrinsics = exports.CustomObject = exports.CustomStringIterator = exports.CustomString = exports.CustomNumber = exports.CustomNil = exports.CustomMapIterator = exports.CustomMap = exports.CustomListIterator = exports.CustomList = exports.CustomFunction = exports.Argument = exports.DefaultType = exports.CustomBoolean = exports.CustomValue = exports.While = exports.Return = exports.ResolveResult = exports.Resolve = exports.OperationSegment = exports.IndexSegment = exports.IdentifierSegment = exports.Reference = exports.Operation = void 0;
|
|
5
5
|
var context_1 = require("./context");
|
|
6
6
|
Object.defineProperty(exports, "ContextState", { enumerable: true, get: function () { return context_1.ContextState; } });
|
|
7
7
|
Object.defineProperty(exports, "ContextType", { enumerable: true, get: function () { return context_1.ContextType; } });
|
|
@@ -127,3 +127,5 @@ var path_1 = require("./utils/path");
|
|
|
127
127
|
Object.defineProperty(exports, "Path", { enumerable: true, get: function () { return path_1.Path; } });
|
|
128
128
|
var deep_equal_1 = require("./utils/deep-equal");
|
|
129
129
|
Object.defineProperty(exports, "deepEqual", { enumerable: true, get: function () { return deep_equal_1.deepEqual; } });
|
|
130
|
+
var deep_hash_1 = require("./utils/deep-hash");
|
|
131
|
+
Object.defineProperty(exports, "deepHash", { enumerable: true, get: function () { return deep_hash_1.deepHash; } });
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ASTEvaluationExpression } from 'miniscript-core';
|
|
2
2
|
import { OperationContext } from '../context';
|
|
3
3
|
import { CustomValue } from '../types/base';
|
|
4
|
-
import { CustomBoolean } from '../types/boolean';
|
|
5
4
|
import { CustomList } from '../types/list';
|
|
6
5
|
import { CustomNumber } from '../types/number';
|
|
7
6
|
import { CustomString } from '../types/string';
|
|
@@ -40,7 +39,7 @@ export declare class Evaluate extends Operation {
|
|
|
40
39
|
constructor(item: ASTEvaluationExpression, target?: string);
|
|
41
40
|
build(visit: CPSVisit): Promise<Operation>;
|
|
42
41
|
resolveBinaryExpression(ctx: OperationContext, expr: Evaluate): Promise<CustomValue>;
|
|
43
|
-
resolveLogicalExpression(ctx: OperationContext, expr: Evaluate): Promise<CustomValue |
|
|
42
|
+
resolveLogicalExpression(ctx: OperationContext, expr: Evaluate): Promise<CustomValue | CustomNumber>;
|
|
44
43
|
resolve(ctx: OperationContext, op: Operation): Promise<CustomValue>;
|
|
45
44
|
handle(ctx: OperationContext): Promise<CustomValue>;
|
|
46
45
|
}
|
|
@@ -22,9 +22,24 @@ const number_1 = require("../types/number");
|
|
|
22
22
|
const string_1 = require("../types/string");
|
|
23
23
|
const deep_equal_1 = require("../utils/deep-equal");
|
|
24
24
|
const operation_1 = require("./operation");
|
|
25
|
+
const absClamp01 = (d) => {
|
|
26
|
+
if (d < 0)
|
|
27
|
+
d = -d;
|
|
28
|
+
if (d > 1)
|
|
29
|
+
return 1;
|
|
30
|
+
return d;
|
|
31
|
+
};
|
|
25
32
|
exports.GenericProcessorHandler = {
|
|
26
|
-
[miniscript_core_1.Operator.And]: (a, b) =>
|
|
27
|
-
|
|
33
|
+
[miniscript_core_1.Operator.And]: (a, b) => {
|
|
34
|
+
const left = Number(a instanceof number_1.CustomNumber ? a.toNumber() : a.toTruthy());
|
|
35
|
+
const right = Number(b instanceof number_1.CustomNumber ? b.toNumber() : b.toTruthy());
|
|
36
|
+
return new number_1.CustomNumber(absClamp01(left * right));
|
|
37
|
+
},
|
|
38
|
+
[miniscript_core_1.Operator.Or]: (a, b) => {
|
|
39
|
+
const left = Number(a instanceof number_1.CustomNumber ? a.toNumber() : a.toTruthy());
|
|
40
|
+
const right = Number(b instanceof number_1.CustomNumber ? b.toNumber() : b.toTruthy());
|
|
41
|
+
return new number_1.CustomNumber(absClamp01(left + right - left * right));
|
|
42
|
+
}
|
|
28
43
|
};
|
|
29
44
|
exports.NumberProcessorHandler = {
|
|
30
45
|
[miniscript_core_1.Operator.Plus]: (a, b) => new number_1.CustomNumber(a.toNumber() + b.toNumber()),
|
|
@@ -317,6 +332,9 @@ class Evaluate extends operation_1.Operation {
|
|
|
317
332
|
return new boolean_1.CustomBoolean(false);
|
|
318
333
|
}
|
|
319
334
|
else if (expr.op === miniscript_core_1.Operator.Or && left.toTruthy()) {
|
|
335
|
+
if (left instanceof number_1.CustomNumber) {
|
|
336
|
+
return new number_1.CustomNumber(absClamp01(left.value));
|
|
337
|
+
}
|
|
320
338
|
return new boolean_1.CustomBoolean(true);
|
|
321
339
|
}
|
|
322
340
|
const right = yield this.resolve(ctx, expr.right);
|
package/dist/types/base.d.ts
CHANGED
package/dist/types/function.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export declare class CustomFunction extends CustomValue {
|
|
|
22
22
|
readonly value: Callback;
|
|
23
23
|
readonly argumentDefs: Array<Argument>;
|
|
24
24
|
readonly assignOuter: boolean;
|
|
25
|
+
readonly id: string;
|
|
25
26
|
private _nextContext;
|
|
26
27
|
static createExternalAnonymous(callback: Callback): CustomFunction;
|
|
27
28
|
static createExternal(name: string, callback: Callback): CustomFunction;
|
package/dist/types/function.js
CHANGED
|
@@ -16,6 +16,7 @@ const operation_1 = require("../operations/operation");
|
|
|
16
16
|
const reference_1 = require("../operations/reference");
|
|
17
17
|
const hash_1 = require("../utils/hash");
|
|
18
18
|
const object_value_1 = require("../utils/object-value");
|
|
19
|
+
const uuid_1 = require("../utils/uuid");
|
|
19
20
|
const base_1 = require("./base");
|
|
20
21
|
const default_1 = require("./default");
|
|
21
22
|
const nil_1 = require("./nil");
|
|
@@ -53,6 +54,7 @@ class CustomFunction extends base_1.CustomValue {
|
|
|
53
54
|
}
|
|
54
55
|
constructor(scope, name, callback, argumentDefs = [], assignOuter = false) {
|
|
55
56
|
super();
|
|
57
|
+
this.id = (0, uuid_1.uuid)();
|
|
56
58
|
this.scope = scope;
|
|
57
59
|
this.name = name;
|
|
58
60
|
this.value = callback;
|
package/dist/types/list.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare class CustomListIterator implements Iterator<CustomValue> {
|
|
|
12
12
|
export declare class CustomList extends CustomObject {
|
|
13
13
|
static readonly intrinsics: ObjectValue;
|
|
14
14
|
static getItemIndex(item: CustomList, index: number): number;
|
|
15
|
+
readonly id: string;
|
|
15
16
|
readonly value: Array<CustomValue>;
|
|
16
17
|
constructor(value?: Array<CustomValue>);
|
|
17
18
|
getCustomType(): string;
|
|
@@ -21,6 +22,7 @@ export declare class CustomList extends CustomObject {
|
|
|
21
22
|
toNumber(): number;
|
|
22
23
|
toInt(): number;
|
|
23
24
|
toTruthy(): boolean;
|
|
25
|
+
getSize(): number;
|
|
24
26
|
instanceOf(v: CustomValue, typeIntrinsics: ContextTypeIntrinsics): boolean;
|
|
25
27
|
slice(a: CustomValue, b: CustomValue): CustomList;
|
|
26
28
|
extend(list: CustomList | Array<CustomValue>): CustomList;
|
package/dist/types/list.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.CustomList = exports.CustomListIterator = void 0;
|
|
|
4
4
|
const hash_1 = require("../utils/hash");
|
|
5
5
|
const object_value_1 = require("../utils/object-value");
|
|
6
6
|
const path_1 = require("../utils/path");
|
|
7
|
+
const uuid_1 = require("../utils/uuid");
|
|
7
8
|
const base_1 = require("./base");
|
|
8
9
|
const number_1 = require("./number");
|
|
9
10
|
const with_intrinsics_1 = require("./with-intrinsics");
|
|
@@ -39,6 +40,7 @@ class CustomList extends with_intrinsics_1.CustomObject {
|
|
|
39
40
|
}
|
|
40
41
|
constructor(value = []) {
|
|
41
42
|
super();
|
|
43
|
+
this.id = (0, uuid_1.uuid)();
|
|
42
44
|
this.value = [...value];
|
|
43
45
|
}
|
|
44
46
|
getCustomType() {
|
|
@@ -62,6 +64,9 @@ class CustomList extends with_intrinsics_1.CustomObject {
|
|
|
62
64
|
toTruthy() {
|
|
63
65
|
return this.value.length > 0;
|
|
64
66
|
}
|
|
67
|
+
getSize() {
|
|
68
|
+
return this.value.length;
|
|
69
|
+
}
|
|
65
70
|
instanceOf(v, typeIntrinsics) {
|
|
66
71
|
var _a;
|
|
67
72
|
return v.value === ((_a = typeIntrinsics.list) !== null && _a !== void 0 ? _a : CustomList.intrinsics);
|
|
@@ -168,7 +173,7 @@ class CustomList extends with_intrinsics_1.CustomObject {
|
|
|
168
173
|
}
|
|
169
174
|
hash(recursionDepth = 0) {
|
|
170
175
|
let result = (0, hash_1.getHashCode)(this.value.length);
|
|
171
|
-
if (recursionDepth >
|
|
176
|
+
if (recursionDepth > 4)
|
|
172
177
|
return result;
|
|
173
178
|
this.value.forEach((value) => {
|
|
174
179
|
result = (0, hash_1.rotateBits)(result) ^ value.hash(recursionDepth + 1);
|
package/dist/types/map.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export declare class CustomMapIterator implements Iterator<CustomValue> {
|
|
|
16
16
|
}
|
|
17
17
|
export declare class CustomMap extends CustomObject {
|
|
18
18
|
static readonly intrinsics: ObjectValue;
|
|
19
|
+
readonly id: string;
|
|
19
20
|
value: ObjectValue;
|
|
20
21
|
private isInstance;
|
|
21
22
|
static createWithInitialValue(value: ObjectValue): CustomMap;
|
|
@@ -27,6 +28,7 @@ export declare class CustomMap extends CustomObject {
|
|
|
27
28
|
toNumber(): number;
|
|
28
29
|
toInt(): number;
|
|
29
30
|
toTruthy(): boolean;
|
|
31
|
+
getSize(): number;
|
|
30
32
|
instanceOf(v: CustomValue, typeIntrinsics: ContextTypeIntrinsics): boolean;
|
|
31
33
|
[Symbol.iterator](): CustomMapIterator;
|
|
32
34
|
extend(map: CustomMap | ObjectValue): CustomMap;
|
package/dist/types/map.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.CustomMap = exports.CustomMapIterator = exports.CUSTOM_MAP_MAX_DEPTH_VAL
|
|
|
4
4
|
const hash_1 = require("../utils/hash");
|
|
5
5
|
const object_value_1 = require("../utils/object-value");
|
|
6
6
|
const path_1 = require("../utils/path");
|
|
7
|
+
const uuid_1 = require("../utils/uuid");
|
|
7
8
|
const base_1 = require("./base");
|
|
8
9
|
const nil_1 = require("./nil");
|
|
9
10
|
const string_1 = require("./string");
|
|
@@ -47,6 +48,7 @@ class CustomMap extends with_intrinsics_1.CustomObject {
|
|
|
47
48
|
constructor(value) {
|
|
48
49
|
super();
|
|
49
50
|
this.isInstance = false;
|
|
51
|
+
this.id = (0, uuid_1.uuid)();
|
|
50
52
|
this.value = new object_value_1.ObjectValue(value);
|
|
51
53
|
}
|
|
52
54
|
getCustomType() {
|
|
@@ -82,6 +84,9 @@ class CustomMap extends with_intrinsics_1.CustomObject {
|
|
|
82
84
|
toTruthy() {
|
|
83
85
|
return this.value.size > 0;
|
|
84
86
|
}
|
|
87
|
+
getSize() {
|
|
88
|
+
return this.value.size;
|
|
89
|
+
}
|
|
85
90
|
instanceOf(v, typeIntrinsics) {
|
|
86
91
|
var _a;
|
|
87
92
|
if (v instanceof CustomMap) {
|
|
@@ -228,7 +233,7 @@ class CustomMap extends with_intrinsics_1.CustomObject {
|
|
|
228
233
|
}
|
|
229
234
|
hash(recursionDepth = 0) {
|
|
230
235
|
let result = (0, hash_1.getHashCode)(this.value.size);
|
|
231
|
-
if (recursionDepth >
|
|
236
|
+
if (recursionDepth > 4)
|
|
232
237
|
return result;
|
|
233
238
|
this.value.forEach((value, key) => {
|
|
234
239
|
result ^= key.hash(recursionDepth + 1);
|
package/dist/types/nil.d.ts
CHANGED
package/dist/types/nil.js
CHANGED
package/dist/types/number.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare class CustomNumberIterator implements Iterator<CustomValue> {
|
|
|
9
9
|
}
|
|
10
10
|
export declare class CustomNumber extends CustomValueWithIntrinsics {
|
|
11
11
|
static readonly intrinsics: ObjectValue;
|
|
12
|
+
readonly id: string;
|
|
12
13
|
readonly value: number;
|
|
13
14
|
constructor(value: number);
|
|
14
15
|
getCustomType(): string;
|
package/dist/types/number.js
CHANGED
package/dist/types/string.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare class CustomStringIterator implements Iterator<CustomValue> {
|
|
|
12
12
|
export declare class CustomString extends CustomValueWithIntrinsics {
|
|
13
13
|
static readonly intrinsics: ObjectValue;
|
|
14
14
|
static getCharIndex(item: CustomString, index: number): number;
|
|
15
|
+
readonly id: string;
|
|
15
16
|
readonly value: string;
|
|
16
17
|
constructor(value: string);
|
|
17
18
|
getCustomType(): string;
|
package/dist/types/string.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { CustomValue } from '../types/base';
|
|
2
|
+
export declare function deepEqual(a: CustomValue, b: CustomValue): boolean;
|
package/dist/utils/deep-equal.js
CHANGED
|
@@ -1,43 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deepEqual = void 0;
|
|
4
|
-
const list_1 = require("../types/list");
|
|
5
|
-
const map_1 = require("../types/map");
|
|
6
4
|
const with_intrinsics_1 = require("../types/with-intrinsics");
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const length = a.value.length;
|
|
17
|
-
if (length !== b.value.length)
|
|
5
|
+
function deepEqual(a, b) {
|
|
6
|
+
const stack = [];
|
|
7
|
+
const visited = new Set();
|
|
8
|
+
stack.push([a, b]);
|
|
9
|
+
while (stack.length > 0) {
|
|
10
|
+
const [a, b] = stack.pop();
|
|
11
|
+
visited.add(`${a.id}:${b.id}`);
|
|
12
|
+
if (a instanceof with_intrinsics_1.CustomObject) {
|
|
13
|
+
if (!(b instanceof with_intrinsics_1.CustomObject))
|
|
18
14
|
return false;
|
|
19
|
-
|
|
20
|
-
if (!
|
|
15
|
+
if (Array.isArray(a.value)) {
|
|
16
|
+
if (!Array.isArray(b.value))
|
|
21
17
|
return false;
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
if (a instanceof map_1.CustomMap) {
|
|
25
|
-
if (a.value.size !== b.value.size)
|
|
26
|
-
return false;
|
|
27
|
-
for (const i of a.value.keys()) {
|
|
28
|
-
if (!b.value.has(i) ||
|
|
29
|
-
!equalInner(a.value.get(i), b.value.get(i), maxDepth, depth + 1)) {
|
|
18
|
+
if (a.value.length !== b.value.length)
|
|
30
19
|
return false;
|
|
20
|
+
for (let index = 0; index < a.value.length; index++) {
|
|
21
|
+
const valueA = a.value[index];
|
|
22
|
+
const valueB = b.value[index];
|
|
23
|
+
if (!visited.has(`${valueA.id}:${valueB.id}`)) {
|
|
24
|
+
stack.push([valueA, valueB]);
|
|
25
|
+
}
|
|
31
26
|
}
|
|
32
27
|
}
|
|
33
|
-
|
|
28
|
+
else {
|
|
29
|
+
if (a.value.size !== b.value.size)
|
|
30
|
+
return false;
|
|
31
|
+
for (const key of a.value.keys()) {
|
|
32
|
+
if (!b.value.has(key))
|
|
33
|
+
return false;
|
|
34
|
+
const valueA = a.value.get(key);
|
|
35
|
+
const valueB = b.value.get(key);
|
|
36
|
+
if (!visited.has(`${valueA.id}:${valueB.id}`)) {
|
|
37
|
+
stack.push([valueA, valueB]);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else if (a.value !== b.value) {
|
|
43
|
+
return false;
|
|
34
44
|
}
|
|
35
|
-
return false;
|
|
36
45
|
}
|
|
37
|
-
|
|
38
|
-
return Number.isNaN(a.value) && Number.isNaN(b.value);
|
|
39
|
-
}
|
|
40
|
-
function deepEqual(a, b, maxDepth = 10) {
|
|
41
|
-
return equalInner(a, b, maxDepth);
|
|
46
|
+
return true;
|
|
42
47
|
}
|
|
43
48
|
exports.deepEqual = deepEqual;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deepHash = void 0;
|
|
4
|
+
const with_intrinsics_1 = require("../types/with-intrinsics");
|
|
5
|
+
const hash_1 = require("./hash");
|
|
6
|
+
function deepHash(value) {
|
|
7
|
+
let result = 0;
|
|
8
|
+
const stack = [];
|
|
9
|
+
const visited = new Set();
|
|
10
|
+
stack.push([value]);
|
|
11
|
+
while (stack.length > 0) {
|
|
12
|
+
const items = stack.pop();
|
|
13
|
+
for (const item of items) {
|
|
14
|
+
visited.add(item.id);
|
|
15
|
+
if (item instanceof with_intrinsics_1.CustomObject) {
|
|
16
|
+
if (Array.isArray(item.value)) {
|
|
17
|
+
result ^= (0, hash_1.getHashCode)(item.value.length);
|
|
18
|
+
for (let index = item.value.length - 1; index >= 0; index--) {
|
|
19
|
+
const child = item.value[index];
|
|
20
|
+
if (!(child instanceof with_intrinsics_1.CustomObject) || !visited.has(child.id))
|
|
21
|
+
stack.push([child]);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
result ^= (0, hash_1.getHashCode)(item.value.length);
|
|
26
|
+
const chunk = [];
|
|
27
|
+
item.value.forEach((child, key) => {
|
|
28
|
+
if (!(key instanceof with_intrinsics_1.CustomObject) || !visited.has(key.id))
|
|
29
|
+
chunk.push(key);
|
|
30
|
+
if (!(child instanceof with_intrinsics_1.CustomObject) || !visited.has(child.id))
|
|
31
|
+
chunk.push(child);
|
|
32
|
+
});
|
|
33
|
+
stack.push(chunk);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
result ^= item.hash();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
result ^= (0, hash_1.rotateBits)(result);
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
exports.deepHash = deepHash;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ObjectValue = void 0;
|
|
4
4
|
const nil_1 = require("../types/nil");
|
|
5
|
+
const deep_hash_1 = require("./deep-hash");
|
|
5
6
|
class ObjectValue {
|
|
6
7
|
constructor(entries) {
|
|
7
8
|
if (entries == null) {
|
|
@@ -21,22 +22,22 @@ class ObjectValue {
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
get(mapKey) {
|
|
24
|
-
const hash =
|
|
25
|
+
const hash = (0, deep_hash_1.deepHash)(mapKey);
|
|
25
26
|
if (!this.data.has(hash))
|
|
26
27
|
return nil_1.Void;
|
|
27
28
|
return this.data.get(hash)[1];
|
|
28
29
|
}
|
|
29
30
|
has(mapKey) {
|
|
30
|
-
const hash =
|
|
31
|
+
const hash = (0, deep_hash_1.deepHash)(mapKey);
|
|
31
32
|
return this.data.has(hash);
|
|
32
33
|
}
|
|
33
34
|
set(mapKey, mapValue) {
|
|
34
|
-
const hash =
|
|
35
|
+
const hash = (0, deep_hash_1.deepHash)(mapKey);
|
|
35
36
|
this.data.set(hash, [mapKey, mapValue]);
|
|
36
37
|
return this;
|
|
37
38
|
}
|
|
38
39
|
delete(mapKey) {
|
|
39
|
-
const hash =
|
|
40
|
+
const hash = (0, deep_hash_1.deepHash)(mapKey);
|
|
40
41
|
return this.data.delete(hash);
|
|
41
42
|
}
|
|
42
43
|
values() {
|