exupery-core-internals 0.1.12 → 0.1.13
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/imp/public/panic.js
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.panic_for_internal_functions = panic_for_internal_functions;
|
|
4
3
|
exports.panic = panic;
|
|
5
|
-
const get_location_info_1 = require("./get_location_info");
|
|
6
|
-
function panic_for_internal_functions(depth, ...message) {
|
|
7
|
-
const location = (0, get_location_info_1.get_location_info)(depth + 1);
|
|
8
|
-
console.error(`PANIC: ${message.join(" ")} @ ${(0, get_location_info_1.location_to_string)(location)}`);
|
|
9
|
-
const e = new Error();
|
|
10
|
-
console.error(e.stack);
|
|
11
|
-
process.exit(1);
|
|
12
|
-
}
|
|
13
4
|
/**
|
|
14
5
|
* call this function if an error is en encountered that is unrecoverable
|
|
15
6
|
* and the application should terminate immediately
|
|
@@ -19,5 +10,5 @@ function panic_for_internal_functions(depth, ...message) {
|
|
|
19
10
|
* @param message message to be printed on stderr
|
|
20
11
|
*/
|
|
21
12
|
function panic(...message) {
|
|
22
|
-
|
|
13
|
+
throw new Error(`PANIC: ${message.join(" ")}`);
|
|
23
14
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ export * from "./imp/public/assert_unreachable";
|
|
|
5
5
|
export * from "./imp/public/change_context";
|
|
6
6
|
export * from "./imp/public/block";
|
|
7
7
|
export * from "./imp/public/switch_state";
|
|
8
|
-
export * from "./imp/public/get_location_info";
|
|
9
8
|
export * from "./imp/public/set";
|
|
10
9
|
export * from "./imp/public/not_set";
|
|
11
10
|
export * from "./transformation";
|
package/dist/index.js
CHANGED
|
@@ -21,7 +21,6 @@ __exportStar(require("./imp/public/assert_unreachable"), exports);
|
|
|
21
21
|
__exportStar(require("./imp/public/change_context"), exports);
|
|
22
22
|
__exportStar(require("./imp/public/block"), exports);
|
|
23
23
|
__exportStar(require("./imp/public/switch_state"), exports);
|
|
24
|
-
__exportStar(require("./imp/public/get_location_info"), exports);
|
|
25
24
|
__exportStar(require("./imp/public/set"), exports);
|
|
26
25
|
__exportStar(require("./imp/public/not_set"), exports);
|
|
27
26
|
__exportStar(require("./transformation"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "exupery-core-internals",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "Corno",
|
|
@@ -17,9 +17,6 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"exupery-core-types": "^0.1.6"
|
|
19
19
|
},
|
|
20
|
-
"devDependencies": {
|
|
21
|
-
"@types/node": "^18.15.3"
|
|
22
|
-
},
|
|
23
20
|
"main": "./dist/index.js",
|
|
24
21
|
"types": "dist/index.d.ts",
|
|
25
22
|
"files": [
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export type Source_Location = {
|
|
2
|
-
'file': string;
|
|
3
|
-
'line': number;
|
|
4
|
-
'column': number;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* provides the source location (filepath and line number) of the source code file where this function is called,
|
|
8
|
-
* or if the depth is bigger than 0, the source location of the function at that stack depth
|
|
9
|
-
* @param depth
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
export declare function get_location_info(depth: number): Source_Location;
|
|
13
|
-
export declare function location_to_string(location: Source_Location): string;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.get_location_info = get_location_info;
|
|
27
|
-
exports.location_to_string = location_to_string;
|
|
28
|
-
const process = __importStar(require("process"));
|
|
29
|
-
const path = __importStar(require("path"));
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
* @returns the string on the specified line
|
|
33
|
-
*/
|
|
34
|
-
function get_line(e, depth) {
|
|
35
|
-
const regex = /\((.*)\)$/;
|
|
36
|
-
//const regex = /\((.*):(\d+):(\d+)\)$/ //further splitted; file,line,column,
|
|
37
|
-
if (e.stack === undefined) {
|
|
38
|
-
throw new Error("NO STACK INFO");
|
|
39
|
-
}
|
|
40
|
-
const line = e.stack.split("\n")[depth + 2];
|
|
41
|
-
const match = regex.exec(line);
|
|
42
|
-
//determine the path relative to the current working directory
|
|
43
|
-
return path.relative(process.cwd(), (() => {
|
|
44
|
-
if (match === null) {
|
|
45
|
-
const begin = " at /";
|
|
46
|
-
if (line.startsWith(begin)) {
|
|
47
|
-
return path.relative(process.cwd(), line.substring(begin.length - 1));
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
throw new Error(`COULD NOT PARSE STACK LINE: ${line}`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
return match[1];
|
|
55
|
-
}
|
|
56
|
-
})());
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* provides the source location (filepath and line number) of the source code file where this function is called,
|
|
60
|
-
* or if the depth is bigger than 0, the source location of the function at that stack depth
|
|
61
|
-
* @param depth
|
|
62
|
-
* @returns
|
|
63
|
-
*/
|
|
64
|
-
function get_location_info(depth) {
|
|
65
|
-
//we create an error, not to be thrown but to be disected for its stack
|
|
66
|
-
const e = new Error(); //don't move this statement to another function, it will change the depth of its stack
|
|
67
|
-
const line = get_line(e, depth);
|
|
68
|
-
const split = line.split(":");
|
|
69
|
-
if (split.length !== 3) {
|
|
70
|
-
throw new Error(`UNEXPECTED LOCATION FORMAT (CHECK THE DEPTH PARAMETER): ${line} (Expected 'file:line:column')`);
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
'file': split[0],
|
|
74
|
-
'line': Number(split[1]),
|
|
75
|
-
'column': Number(split[2]),
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
function location_to_string(location) {
|
|
79
|
-
return `${location.file}:${location.line}:${location.column}`;
|
|
80
|
-
}
|