greybel-interpreter 1.3.7 → 1.3.8
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/.editorconfig +14 -14
- package/.eslintrc +47 -47
- package/LICENSE +21 -21
- package/README.md +2 -2
- package/dist/context.d.ts +109 -109
- package/dist/context.js +383 -382
- package/dist/cps.d.ts +14 -14
- package/dist/cps.js +213 -213
- package/dist/handler/error.d.ts +6 -6
- package/dist/handler/error.js +35 -35
- package/dist/handler/output.d.ts +18 -18
- package/dist/handler/output.js +52 -52
- package/dist/handler/resource.d.ts +12 -12
- package/dist/handler/resource.js +51 -51
- package/dist/handler-container.d.ts +14 -14
- package/dist/handler-container.js +16 -16
- package/dist/index.d.ts +45 -45
- package/dist/index.js +131 -131
- package/dist/interpreter.d.ts +41 -41
- package/dist/interpreter.js +312 -312
- package/dist/intrinsics-container.d.ts +7 -7
- package/dist/intrinsics-container.js +19 -19
- package/dist/operations/assign.d.ts +13 -13
- package/dist/operations/assign.js +111 -111
- package/dist/operations/block.d.ts +12 -12
- package/dist/operations/block.js +108 -108
- package/dist/operations/break.d.ts +10 -10
- package/dist/operations/break.js +41 -41
- package/dist/operations/call.d.ts +13 -13
- package/dist/operations/call.js +124 -124
- package/dist/operations/chunk.d.ts +12 -12
- package/dist/operations/chunk.js +85 -85
- package/dist/operations/continue.d.ts +10 -10
- package/dist/operations/continue.js +41 -41
- package/dist/operations/debugger-statement.d.ts +10 -10
- package/dist/operations/debugger-statement.js +39 -39
- package/dist/operations/evaluate.d.ts +41 -39
- package/dist/operations/evaluate.js +433 -367
- package/dist/operations/for.d.ts +14 -14
- package/dist/operations/for.js +152 -152
- package/dist/operations/function-reference.d.ts +12 -12
- package/dist/operations/function-reference.js +103 -103
- package/dist/operations/function.d.ts +14 -14
- package/dist/operations/function.js +200 -200
- package/dist/operations/if-statement.d.ts +19 -19
- package/dist/operations/if-statement.js +181 -181
- package/dist/operations/import.d.ts +17 -17
- package/dist/operations/import.js +119 -119
- package/dist/operations/include.d.ts +13 -13
- package/dist/operations/include.js +95 -95
- package/dist/operations/list.d.ts +11 -11
- package/dist/operations/list.js +111 -111
- package/dist/operations/literal.d.ts +11 -11
- package/dist/operations/literal.js +58 -58
- package/dist/operations/map.d.ts +11 -11
- package/dist/operations/map.js +171 -171
- package/dist/operations/negated-binary.d.ts +11 -11
- package/dist/operations/negated-binary.js +109 -109
- package/dist/operations/new-instance.d.ts +11 -11
- package/dist/operations/new-instance.js +100 -100
- package/dist/operations/noop.d.ts +9 -9
- package/dist/operations/noop.js +36 -36
- package/dist/operations/not.d.ts +11 -11
- package/dist/operations/not.js +96 -96
- package/dist/operations/operation.d.ts +13 -13
- package/dist/operations/operation.js +11 -11
- package/dist/operations/reference.d.ts +9 -9
- package/dist/operations/reference.js +37 -37
- package/dist/operations/resolve.d.ts +38 -38
- package/dist/operations/resolve.js +330 -330
- package/dist/operations/return.d.ts +11 -11
- package/dist/operations/return.js +107 -107
- package/dist/operations/while.d.ts +13 -13
- package/dist/operations/while.js +136 -136
- package/dist/types/boolean.d.ts +11 -11
- package/dist/types/boolean.js +46 -46
- package/dist/types/default.d.ts +11 -11
- package/dist/types/default.js +20 -20
- package/dist/types/function.d.ts +32 -32
- package/dist/types/function.js +174 -174
- package/dist/types/generics.d.ts +18 -18
- package/dist/types/generics.js +40 -40
- package/dist/types/interface.d.ts +23 -23
- package/dist/types/interface.js +103 -103
- package/dist/types/list.d.ts +31 -31
- package/dist/types/list.js +209 -209
- package/dist/types/map.d.ts +37 -37
- package/dist/types/map.js +366 -366
- package/dist/types/nil.d.ts +10 -10
- package/dist/types/nil.js +46 -46
- package/dist/types/number.d.ts +11 -11
- package/dist/types/number.js +46 -46
- package/dist/types/string.d.ts +33 -33
- package/dist/types/string.js +145 -145
- package/dist/utils/deep-equal.d.ts +1 -1
- package/dist/utils/deep-equal.js +62 -62
- package/dist/utils/path.d.ts +10 -10
- package/dist/utils/path.js +59 -59
- package/package.json +58 -58
package/dist/types/nil.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { CustomValue } from './generics';
|
|
2
|
-
export default class CustomNil extends CustomValue {
|
|
3
|
-
value: null;
|
|
4
|
-
getCustomType(): string;
|
|
5
|
-
toString(): string;
|
|
6
|
-
fork(): CustomNil;
|
|
7
|
-
toNumber(): number;
|
|
8
|
-
toInt(): number;
|
|
9
|
-
toTruthy(): boolean;
|
|
10
|
-
}
|
|
1
|
+
import { CustomValue } from './generics';
|
|
2
|
+
export default class CustomNil extends CustomValue {
|
|
3
|
+
value: null;
|
|
4
|
+
getCustomType(): string;
|
|
5
|
+
toString(): string;
|
|
6
|
+
fork(): CustomNil;
|
|
7
|
+
toNumber(): number;
|
|
8
|
+
toInt(): number;
|
|
9
|
+
toTruthy(): boolean;
|
|
10
|
+
}
|
package/dist/types/nil.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
var generics_1 = require("./generics");
|
|
19
|
-
var CustomNil = /** @class */ (function (_super) {
|
|
20
|
-
__extends(CustomNil, _super);
|
|
21
|
-
function CustomNil() {
|
|
22
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
23
|
-
_this.value = null;
|
|
24
|
-
return _this;
|
|
25
|
-
}
|
|
26
|
-
CustomNil.prototype.getCustomType = function () {
|
|
27
|
-
return 'null';
|
|
28
|
-
};
|
|
29
|
-
CustomNil.prototype.toString = function () {
|
|
30
|
-
return '';
|
|
31
|
-
};
|
|
32
|
-
CustomNil.prototype.fork = function () {
|
|
33
|
-
return new CustomNil();
|
|
34
|
-
};
|
|
35
|
-
CustomNil.prototype.toNumber = function () {
|
|
36
|
-
return undefined;
|
|
37
|
-
};
|
|
38
|
-
CustomNil.prototype.toInt = function () {
|
|
39
|
-
return undefined;
|
|
40
|
-
};
|
|
41
|
-
CustomNil.prototype.toTruthy = function () {
|
|
42
|
-
return false;
|
|
43
|
-
};
|
|
44
|
-
return CustomNil;
|
|
45
|
-
}(generics_1.CustomValue));
|
|
46
|
-
exports.default = CustomNil;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
var generics_1 = require("./generics");
|
|
19
|
+
var CustomNil = /** @class */ (function (_super) {
|
|
20
|
+
__extends(CustomNil, _super);
|
|
21
|
+
function CustomNil() {
|
|
22
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
23
|
+
_this.value = null;
|
|
24
|
+
return _this;
|
|
25
|
+
}
|
|
26
|
+
CustomNil.prototype.getCustomType = function () {
|
|
27
|
+
return 'null';
|
|
28
|
+
};
|
|
29
|
+
CustomNil.prototype.toString = function () {
|
|
30
|
+
return 'null';
|
|
31
|
+
};
|
|
32
|
+
CustomNil.prototype.fork = function () {
|
|
33
|
+
return new CustomNil();
|
|
34
|
+
};
|
|
35
|
+
CustomNil.prototype.toNumber = function () {
|
|
36
|
+
return undefined;
|
|
37
|
+
};
|
|
38
|
+
CustomNil.prototype.toInt = function () {
|
|
39
|
+
return undefined;
|
|
40
|
+
};
|
|
41
|
+
CustomNil.prototype.toTruthy = function () {
|
|
42
|
+
return false;
|
|
43
|
+
};
|
|
44
|
+
return CustomNil;
|
|
45
|
+
}(generics_1.CustomValue));
|
|
46
|
+
exports.default = CustomNil;
|
package/dist/types/number.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { CustomValue } from './generics';
|
|
2
|
-
export default class CustomNumber extends CustomValue {
|
|
3
|
-
readonly value: number;
|
|
4
|
-
constructor(value: number);
|
|
5
|
-
getCustomType(): string;
|
|
6
|
-
toString(): string;
|
|
7
|
-
fork(): CustomNumber;
|
|
8
|
-
toInt(): number;
|
|
9
|
-
toNumber(): number;
|
|
10
|
-
toTruthy(): boolean;
|
|
11
|
-
}
|
|
1
|
+
import { CustomValue } from './generics';
|
|
2
|
+
export default class CustomNumber extends CustomValue {
|
|
3
|
+
readonly value: number;
|
|
4
|
+
constructor(value: number);
|
|
5
|
+
getCustomType(): string;
|
|
6
|
+
toString(): string;
|
|
7
|
+
fork(): CustomNumber;
|
|
8
|
+
toInt(): number;
|
|
9
|
+
toNumber(): number;
|
|
10
|
+
toTruthy(): boolean;
|
|
11
|
+
}
|
package/dist/types/number.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
var generics_1 = require("./generics");
|
|
19
|
-
var CustomNumber = /** @class */ (function (_super) {
|
|
20
|
-
__extends(CustomNumber, _super);
|
|
21
|
-
function CustomNumber(value) {
|
|
22
|
-
var _this = _super.call(this) || this;
|
|
23
|
-
_this.value = value;
|
|
24
|
-
return _this;
|
|
25
|
-
}
|
|
26
|
-
CustomNumber.prototype.getCustomType = function () {
|
|
27
|
-
return 'number';
|
|
28
|
-
};
|
|
29
|
-
CustomNumber.prototype.toString = function () {
|
|
30
|
-
return this.value.toString();
|
|
31
|
-
};
|
|
32
|
-
CustomNumber.prototype.fork = function () {
|
|
33
|
-
return new CustomNumber(this.value);
|
|
34
|
-
};
|
|
35
|
-
CustomNumber.prototype.toInt = function () {
|
|
36
|
-
return this.value | 0;
|
|
37
|
-
};
|
|
38
|
-
CustomNumber.prototype.toNumber = function () {
|
|
39
|
-
return this.value;
|
|
40
|
-
};
|
|
41
|
-
CustomNumber.prototype.toTruthy = function () {
|
|
42
|
-
return !!this.value;
|
|
43
|
-
};
|
|
44
|
-
return CustomNumber;
|
|
45
|
-
}(generics_1.CustomValue));
|
|
46
|
-
exports.default = CustomNumber;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
var generics_1 = require("./generics");
|
|
19
|
+
var CustomNumber = /** @class */ (function (_super) {
|
|
20
|
+
__extends(CustomNumber, _super);
|
|
21
|
+
function CustomNumber(value) {
|
|
22
|
+
var _this = _super.call(this) || this;
|
|
23
|
+
_this.value = value;
|
|
24
|
+
return _this;
|
|
25
|
+
}
|
|
26
|
+
CustomNumber.prototype.getCustomType = function () {
|
|
27
|
+
return 'number';
|
|
28
|
+
};
|
|
29
|
+
CustomNumber.prototype.toString = function () {
|
|
30
|
+
return this.value.toString();
|
|
31
|
+
};
|
|
32
|
+
CustomNumber.prototype.fork = function () {
|
|
33
|
+
return new CustomNumber(this.value);
|
|
34
|
+
};
|
|
35
|
+
CustomNumber.prototype.toInt = function () {
|
|
36
|
+
return this.value | 0;
|
|
37
|
+
};
|
|
38
|
+
CustomNumber.prototype.toNumber = function () {
|
|
39
|
+
return this.value;
|
|
40
|
+
};
|
|
41
|
+
CustomNumber.prototype.toTruthy = function () {
|
|
42
|
+
return !!this.value;
|
|
43
|
+
};
|
|
44
|
+
return CustomNumber;
|
|
45
|
+
}(generics_1.CustomValue));
|
|
46
|
+
exports.default = CustomNumber;
|
package/dist/types/string.d.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import IntrinsicsContainer from '../intrinsics-container';
|
|
2
|
-
import Path from '../utils/path';
|
|
3
|
-
import CustomFunction from './function';
|
|
4
|
-
import { CustomValue, CustomValueWithIntrinsics } from './generics';
|
|
5
|
-
export declare class CustomStringIterator implements Iterator<CustomValue> {
|
|
6
|
-
value: string;
|
|
7
|
-
index: number;
|
|
8
|
-
constructor(value: string);
|
|
9
|
-
next(): IteratorResult<CustomValue>;
|
|
10
|
-
}
|
|
11
|
-
export default class CustomString extends CustomValueWithIntrinsics {
|
|
12
|
-
static getCharIndex(item: CustomString, index: number): number;
|
|
13
|
-
private static intrinsics;
|
|
14
|
-
static getIntrinsics(): IntrinsicsContainer;
|
|
15
|
-
static addIntrinsic(name: string, fn: CustomFunction): void;
|
|
16
|
-
readonly value: string;
|
|
17
|
-
constructor(value: string);
|
|
18
|
-
getCustomType(): string;
|
|
19
|
-
toString(): string;
|
|
20
|
-
fork(): CustomString;
|
|
21
|
-
isNumber(): boolean;
|
|
22
|
-
parseFloat(): number;
|
|
23
|
-
parseInt(): number;
|
|
24
|
-
toNumber(): number;
|
|
25
|
-
toInt(): number;
|
|
26
|
-
toTruthy(): boolean;
|
|
27
|
-
slice(a: CustomValue, b: CustomValue): CustomString;
|
|
28
|
-
[Symbol.iterator](): CustomStringIterator;
|
|
29
|
-
getCharIndex(index: number): number;
|
|
30
|
-
has(path: Path<CustomValue> | CustomValue): boolean;
|
|
31
|
-
set(_path: Path<CustomValue> | CustomValue, _newValue: CustomValue): void;
|
|
32
|
-
get(path: Path<CustomValue> | CustomValue): CustomValue;
|
|
33
|
-
}
|
|
1
|
+
import IntrinsicsContainer from '../intrinsics-container';
|
|
2
|
+
import Path from '../utils/path';
|
|
3
|
+
import CustomFunction from './function';
|
|
4
|
+
import { CustomValue, CustomValueWithIntrinsics } from './generics';
|
|
5
|
+
export declare class CustomStringIterator implements Iterator<CustomValue> {
|
|
6
|
+
value: string;
|
|
7
|
+
index: number;
|
|
8
|
+
constructor(value: string);
|
|
9
|
+
next(): IteratorResult<CustomValue>;
|
|
10
|
+
}
|
|
11
|
+
export default class CustomString extends CustomValueWithIntrinsics {
|
|
12
|
+
static getCharIndex(item: CustomString, index: number): number;
|
|
13
|
+
private static intrinsics;
|
|
14
|
+
static getIntrinsics(): IntrinsicsContainer;
|
|
15
|
+
static addIntrinsic(name: string, fn: CustomFunction): void;
|
|
16
|
+
readonly value: string;
|
|
17
|
+
constructor(value: string);
|
|
18
|
+
getCustomType(): string;
|
|
19
|
+
toString(): string;
|
|
20
|
+
fork(): CustomString;
|
|
21
|
+
isNumber(): boolean;
|
|
22
|
+
parseFloat(): number;
|
|
23
|
+
parseInt(): number;
|
|
24
|
+
toNumber(): number;
|
|
25
|
+
toInt(): number;
|
|
26
|
+
toTruthy(): boolean;
|
|
27
|
+
slice(a: CustomValue, b: CustomValue): CustomString;
|
|
28
|
+
[Symbol.iterator](): CustomStringIterator;
|
|
29
|
+
getCharIndex(index: number): number;
|
|
30
|
+
has(path: Path<CustomValue> | CustomValue): boolean;
|
|
31
|
+
set(_path: Path<CustomValue> | CustomValue, _newValue: CustomValue): void;
|
|
32
|
+
get(path: Path<CustomValue> | CustomValue): CustomValue;
|
|
33
|
+
}
|
package/dist/types/string.js
CHANGED
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
-
};
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.CustomStringIterator = void 0;
|
|
22
|
-
var intrinsics_container_1 = __importDefault(require("../intrinsics-container"));
|
|
23
|
-
var path_1 = __importDefault(require("../utils/path"));
|
|
24
|
-
var default_1 = __importDefault(require("./default"));
|
|
25
|
-
var generics_1 = require("./generics");
|
|
26
|
-
var number_1 = __importDefault(require("./number"));
|
|
27
|
-
var CustomStringIterator = /** @class */ (function () {
|
|
28
|
-
function CustomStringIterator(value) {
|
|
29
|
-
var me = this;
|
|
30
|
-
me.value = value;
|
|
31
|
-
me.index = 0;
|
|
32
|
-
}
|
|
33
|
-
CustomStringIterator.prototype.next = function () {
|
|
34
|
-
var me = this;
|
|
35
|
-
if (me.index === me.value.length) {
|
|
36
|
-
return {
|
|
37
|
-
value: null,
|
|
38
|
-
done: true
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
value: new CustomString(me.value[me.index++]),
|
|
43
|
-
done: false
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
return CustomStringIterator;
|
|
47
|
-
}());
|
|
48
|
-
exports.CustomStringIterator = CustomStringIterator;
|
|
49
|
-
var CustomString = /** @class */ (function (_super) {
|
|
50
|
-
__extends(CustomString, _super);
|
|
51
|
-
function CustomString(value) {
|
|
52
|
-
var _this = _super.call(this) || this;
|
|
53
|
-
_this.value = value;
|
|
54
|
-
return _this;
|
|
55
|
-
}
|
|
56
|
-
CustomString.getCharIndex = function (item, index) {
|
|
57
|
-
var n = index | 0;
|
|
58
|
-
if (n < 0)
|
|
59
|
-
n += item.value.length;
|
|
60
|
-
if (n < 0 || n >= item.value.length)
|
|
61
|
-
return -1;
|
|
62
|
-
return n;
|
|
63
|
-
};
|
|
64
|
-
CustomString.getIntrinsics = function () {
|
|
65
|
-
return this.intrinsics;
|
|
66
|
-
};
|
|
67
|
-
CustomString.addIntrinsic = function (name, fn) {
|
|
68
|
-
this.intrinsics.add(name, fn);
|
|
69
|
-
};
|
|
70
|
-
CustomString.prototype.getCustomType = function () {
|
|
71
|
-
return 'string';
|
|
72
|
-
};
|
|
73
|
-
CustomString.prototype.toString = function () {
|
|
74
|
-
return this.value;
|
|
75
|
-
};
|
|
76
|
-
CustomString.prototype.fork = function () {
|
|
77
|
-
return new CustomString(this.value);
|
|
78
|
-
};
|
|
79
|
-
CustomString.prototype.isNumber = function () {
|
|
80
|
-
var nr = Number(this.value);
|
|
81
|
-
return !Number.isNaN(nr);
|
|
82
|
-
};
|
|
83
|
-
CustomString.prototype.parseFloat = function () {
|
|
84
|
-
return parseFloat(this.value);
|
|
85
|
-
};
|
|
86
|
-
CustomString.prototype.parseInt = function () {
|
|
87
|
-
return parseInt(this.value);
|
|
88
|
-
};
|
|
89
|
-
CustomString.prototype.toNumber = function () {
|
|
90
|
-
return 0;
|
|
91
|
-
};
|
|
92
|
-
CustomString.prototype.toInt = function () {
|
|
93
|
-
return 0;
|
|
94
|
-
};
|
|
95
|
-
CustomString.prototype.toTruthy = function () {
|
|
96
|
-
return this.value.length > 0;
|
|
97
|
-
};
|
|
98
|
-
CustomString.prototype.slice = function (a, b) {
|
|
99
|
-
return new CustomString(this.value.slice(a.toNumber(), b.toNumber()));
|
|
100
|
-
};
|
|
101
|
-
CustomString.prototype[Symbol.iterator] = function () {
|
|
102
|
-
return new CustomStringIterator(this.value);
|
|
103
|
-
};
|
|
104
|
-
CustomString.prototype.getCharIndex = function (index) {
|
|
105
|
-
return CustomString.getCharIndex(this, index);
|
|
106
|
-
};
|
|
107
|
-
CustomString.prototype.has = function (path) {
|
|
108
|
-
if (path instanceof generics_1.CustomValue) {
|
|
109
|
-
return this.has(new path_1.default([path]));
|
|
110
|
-
}
|
|
111
|
-
var traversalPath = path.clone();
|
|
112
|
-
var current = traversalPath.next();
|
|
113
|
-
if (current instanceof number_1.default) {
|
|
114
|
-
var index = current.toInt();
|
|
115
|
-
return !!this.value[index];
|
|
116
|
-
}
|
|
117
|
-
return false;
|
|
118
|
-
};
|
|
119
|
-
CustomString.prototype.set = function (_path, _newValue) {
|
|
120
|
-
throw new Error('Mutable operations are not allowed on a string.');
|
|
121
|
-
};
|
|
122
|
-
CustomString.prototype.get = function (path) {
|
|
123
|
-
if (path instanceof generics_1.CustomValue) {
|
|
124
|
-
return this.get(new path_1.default([path]));
|
|
125
|
-
}
|
|
126
|
-
var traversalPath = path.clone();
|
|
127
|
-
var current = traversalPath.next();
|
|
128
|
-
if (current instanceof number_1.default) {
|
|
129
|
-
var currentIndex = this.getCharIndex(current.toInt());
|
|
130
|
-
var segment = this.value[currentIndex];
|
|
131
|
-
if (segment) {
|
|
132
|
-
return new CustomString(segment);
|
|
133
|
-
}
|
|
134
|
-
throw new Error("Index error (string index ".concat(currentIndex, " out of range)."));
|
|
135
|
-
}
|
|
136
|
-
else if (path.count() === 1 &&
|
|
137
|
-
CustomString.getIntrinsics().has(current.toString())) {
|
|
138
|
-
return CustomString.intrinsics.get(current.toString());
|
|
139
|
-
}
|
|
140
|
-
return default_1.default.Void;
|
|
141
|
-
};
|
|
142
|
-
CustomString.intrinsics = new intrinsics_container_1.default();
|
|
143
|
-
return CustomString;
|
|
144
|
-
}(generics_1.CustomValueWithIntrinsics));
|
|
145
|
-
exports.default = CustomString;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.CustomStringIterator = void 0;
|
|
22
|
+
var intrinsics_container_1 = __importDefault(require("../intrinsics-container"));
|
|
23
|
+
var path_1 = __importDefault(require("../utils/path"));
|
|
24
|
+
var default_1 = __importDefault(require("./default"));
|
|
25
|
+
var generics_1 = require("./generics");
|
|
26
|
+
var number_1 = __importDefault(require("./number"));
|
|
27
|
+
var CustomStringIterator = /** @class */ (function () {
|
|
28
|
+
function CustomStringIterator(value) {
|
|
29
|
+
var me = this;
|
|
30
|
+
me.value = value;
|
|
31
|
+
me.index = 0;
|
|
32
|
+
}
|
|
33
|
+
CustomStringIterator.prototype.next = function () {
|
|
34
|
+
var me = this;
|
|
35
|
+
if (me.index === me.value.length) {
|
|
36
|
+
return {
|
|
37
|
+
value: null,
|
|
38
|
+
done: true
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
value: new CustomString(me.value[me.index++]),
|
|
43
|
+
done: false
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
return CustomStringIterator;
|
|
47
|
+
}());
|
|
48
|
+
exports.CustomStringIterator = CustomStringIterator;
|
|
49
|
+
var CustomString = /** @class */ (function (_super) {
|
|
50
|
+
__extends(CustomString, _super);
|
|
51
|
+
function CustomString(value) {
|
|
52
|
+
var _this = _super.call(this) || this;
|
|
53
|
+
_this.value = value;
|
|
54
|
+
return _this;
|
|
55
|
+
}
|
|
56
|
+
CustomString.getCharIndex = function (item, index) {
|
|
57
|
+
var n = index | 0;
|
|
58
|
+
if (n < 0)
|
|
59
|
+
n += item.value.length;
|
|
60
|
+
if (n < 0 || n >= item.value.length)
|
|
61
|
+
return -1;
|
|
62
|
+
return n;
|
|
63
|
+
};
|
|
64
|
+
CustomString.getIntrinsics = function () {
|
|
65
|
+
return this.intrinsics;
|
|
66
|
+
};
|
|
67
|
+
CustomString.addIntrinsic = function (name, fn) {
|
|
68
|
+
this.intrinsics.add(name, fn);
|
|
69
|
+
};
|
|
70
|
+
CustomString.prototype.getCustomType = function () {
|
|
71
|
+
return 'string';
|
|
72
|
+
};
|
|
73
|
+
CustomString.prototype.toString = function () {
|
|
74
|
+
return this.value;
|
|
75
|
+
};
|
|
76
|
+
CustomString.prototype.fork = function () {
|
|
77
|
+
return new CustomString(this.value);
|
|
78
|
+
};
|
|
79
|
+
CustomString.prototype.isNumber = function () {
|
|
80
|
+
var nr = Number(this.value);
|
|
81
|
+
return !Number.isNaN(nr);
|
|
82
|
+
};
|
|
83
|
+
CustomString.prototype.parseFloat = function () {
|
|
84
|
+
return parseFloat(this.value);
|
|
85
|
+
};
|
|
86
|
+
CustomString.prototype.parseInt = function () {
|
|
87
|
+
return parseInt(this.value);
|
|
88
|
+
};
|
|
89
|
+
CustomString.prototype.toNumber = function () {
|
|
90
|
+
return 0;
|
|
91
|
+
};
|
|
92
|
+
CustomString.prototype.toInt = function () {
|
|
93
|
+
return 0;
|
|
94
|
+
};
|
|
95
|
+
CustomString.prototype.toTruthy = function () {
|
|
96
|
+
return this.value.length > 0;
|
|
97
|
+
};
|
|
98
|
+
CustomString.prototype.slice = function (a, b) {
|
|
99
|
+
return new CustomString(this.value.slice(a.toNumber(), b.toNumber()));
|
|
100
|
+
};
|
|
101
|
+
CustomString.prototype[Symbol.iterator] = function () {
|
|
102
|
+
return new CustomStringIterator(this.value);
|
|
103
|
+
};
|
|
104
|
+
CustomString.prototype.getCharIndex = function (index) {
|
|
105
|
+
return CustomString.getCharIndex(this, index);
|
|
106
|
+
};
|
|
107
|
+
CustomString.prototype.has = function (path) {
|
|
108
|
+
if (path instanceof generics_1.CustomValue) {
|
|
109
|
+
return this.has(new path_1.default([path]));
|
|
110
|
+
}
|
|
111
|
+
var traversalPath = path.clone();
|
|
112
|
+
var current = traversalPath.next();
|
|
113
|
+
if (current instanceof number_1.default) {
|
|
114
|
+
var index = current.toInt();
|
|
115
|
+
return !!this.value[index];
|
|
116
|
+
}
|
|
117
|
+
return false;
|
|
118
|
+
};
|
|
119
|
+
CustomString.prototype.set = function (_path, _newValue) {
|
|
120
|
+
throw new Error('Mutable operations are not allowed on a string.');
|
|
121
|
+
};
|
|
122
|
+
CustomString.prototype.get = function (path) {
|
|
123
|
+
if (path instanceof generics_1.CustomValue) {
|
|
124
|
+
return this.get(new path_1.default([path]));
|
|
125
|
+
}
|
|
126
|
+
var traversalPath = path.clone();
|
|
127
|
+
var current = traversalPath.next();
|
|
128
|
+
if (current instanceof number_1.default) {
|
|
129
|
+
var currentIndex = this.getCharIndex(current.toInt());
|
|
130
|
+
var segment = this.value[currentIndex];
|
|
131
|
+
if (segment) {
|
|
132
|
+
return new CustomString(segment);
|
|
133
|
+
}
|
|
134
|
+
throw new Error("Index error (string index ".concat(currentIndex, " out of range)."));
|
|
135
|
+
}
|
|
136
|
+
else if (path.count() === 1 &&
|
|
137
|
+
CustomString.getIntrinsics().has(current.toString())) {
|
|
138
|
+
return CustomString.intrinsics.get(current.toString());
|
|
139
|
+
}
|
|
140
|
+
return default_1.default.Void;
|
|
141
|
+
};
|
|
142
|
+
CustomString.intrinsics = new intrinsics_container_1.default();
|
|
143
|
+
return CustomString;
|
|
144
|
+
}(generics_1.CustomValueWithIntrinsics));
|
|
145
|
+
exports.default = CustomString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function equal(a: any, b: any, maxDepth?: number): boolean;
|
|
1
|
+
export default function equal(a: any, b: any, maxDepth?: number): boolean;
|