pareto-core-dev 0.11.0 → 0.11.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.
@@ -1,7 +1,30 @@
1
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
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.implement_me = implement_me;
4
- const get_location_info_1 = require("../get_location_info");
27
+ const _pint = __importStar(require("pareto-core-internals"));
5
28
  /**
6
29
  * use this function as a placeholder when you want to compile but have not fully developed all functionality yet.
7
30
  *
@@ -10,5 +33,5 @@ const get_location_info_1 = require("../get_location_info");
10
33
  * @param message the string to be printed to stderr
11
34
  */
12
35
  function implement_me(marker) {
13
- throw new Error(`IMPLEMENT ME ${marker ? `: '${marker}'` : ''}@ ${(0, get_location_info_1.location_to_string)((0, get_location_info_1.get_location_info)(1))}`);
36
+ throw new Error(`IMPLEMENT ME ${marker ? `: '${marker}'` : ''}@ ${_pint.location_to_string(_pint.get_location_info(1))}`);
14
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pareto-core-dev",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "license": "ISC",
5
5
  "description": "a pareto package that contains functions that are useful during development",
6
6
  "author": "Corno",
@@ -23,5 +23,7 @@
23
23
  "type": "git",
24
24
  "url": "git+https://github.com/corno/pareto-core-dev.git"
25
25
  },
26
- "dependencies": {}
26
+ "dependencies": {
27
+ "pareto-core-internals": "^0.24.10"
28
+ }
27
29
  }
@@ -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,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.get_location_info = get_location_info;
4
- exports.location_to_string = location_to_string;
5
- /**
6
- * provides the source location (filepath and line number) of the source code file where this function is called,
7
- * or if the depth is bigger than 0, the source location of the function at that stack depth
8
- * @param depth
9
- * @returns
10
- */
11
- function get_location_info(depth) {
12
- //we create an error, not to be thrown but to be disected for its stack
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
- }
31
- const line = get_line(e, depth);
32
- const split = line.split(":");
33
- if (split.length !== 3) {
34
- throw new Error(`UNEXPECTED LOCATION FORMAT (CHECK THE DEPTH PARAMETER): ${line} (Expected 'file:line:column')`);
35
- }
36
- return {
37
- 'file': split[0],
38
- 'line': Number(split[1]),
39
- 'column': Number(split[2]),
40
- };
41
- }
42
- function location_to_string(location) {
43
- return `${location.file}:${location.line}:${location.column}`;
44
- }