exupery-core-dev 0.3.0 → 0.3.1

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.
@@ -2,36 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.get_location_info = get_location_info;
4
4
  exports.location_to_string = location_to_string;
5
- const process_1 = require("process");
6
- const path_1 = require("path");
7
- /**
8
- *
9
- * @returns the string on the specified line
10
- */
11
- function get_line(e, depth) {
12
- const regex = /\((.*)\)$/;
13
- //const regex = /\((.*):(\d+):(\d+)\)$/ //further splitted; file,line,column,
14
- if (e.stack === undefined) {
15
- throw new Error("NO STACK INFO");
16
- }
17
- const line = e.stack.split("\n")[depth + 2];
18
- const match = regex.exec(line);
19
- //determine the path relative to the current working directory
20
- return (0, path_1.relative)((0, process_1.cwd)(), (() => {
21
- if (match === null) {
22
- const begin = " at /";
23
- if (line.startsWith(begin)) {
24
- return (0, path_1.relative)((0, process_1.cwd)(), line.substring(begin.length - 1));
25
- }
26
- else {
27
- throw new Error(`COULD NOT PARSE STACK LINE: ${line}`);
28
- }
29
- }
30
- else {
31
- return match[1];
32
- }
33
- })());
34
- }
35
5
  /**
36
6
  * provides the source location (filepath and line number) of the source code file where this function is called,
37
7
  * or if the depth is bigger than 0, the source location of the function at that stack depth
@@ -41,6 +11,23 @@ function get_line(e, depth) {
41
11
  function get_location_info(depth) {
42
12
  //we create an error, not to be thrown but to be disected for its stack
43
13
  const e = new Error(); //don't move this statement to another function, it will change the depth of its stack
14
+ function get_line(e, depth) {
15
+ if (e.stack === undefined) {
16
+ throw new Error(`NO STACK INFO`);
17
+ }
18
+ const line = e.stack.split("\n")[depth + 2]; //get the right line from the stack (the first two lines are "Error" and this function call)
19
+ const regex = /\((.*)\)$/; //matches the content inside parentheses at the end of a line (the file path with line and column)
20
+ const match = regex.exec(line);
21
+ if (match !== null) {
22
+ //we have a match
23
+ return match[1];
24
+ }
25
+ const begin = " at /";
26
+ if (line.startsWith(begin)) {
27
+ return line.substring(begin.length - 1);
28
+ }
29
+ throw new Error(`COULD NOT PARSE STACK LINE: ${line}`);
30
+ }
44
31
  const line = get_line(e, depth);
45
32
  const split = line.split(":");
46
33
  if (split.length !== 3) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exupery-core-dev",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "license": "ISC",
5
5
  "description": "a exupery package that contains functions that are useful during development",
6
6
  "author": "Corno",
@@ -25,8 +25,5 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "exupery-core-internals": "^0.3.0"
28
- },
29
- "devDependencies": {
30
- "@types/node": "^24.9.1"
31
28
  }
32
29
  }