exupery-core-data 0.3.0 → 0.3.2

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/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { get_location_info, location_to_string, Source_Location, } from "./get_location_info";
2
- export { array_literal as a, //this function is heavily used, to not clutter the code, it is abbreviated to just 'a'
2
+ export { list_literal as a, //this function is heavily used, to not clutter the code, it is abbreviated to just 'a'
3
3
  dictionary_literal as d, //this function is heavily used, to not clutter the code, it is abbreviated to just 'd'
4
4
  set, not_set, } from "exupery-core-internals";
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ var get_location_info_1 = require("./get_location_info");
5
5
  Object.defineProperty(exports, "get_location_info", { enumerable: true, get: function () { return get_location_info_1.get_location_info; } });
6
6
  Object.defineProperty(exports, "location_to_string", { enumerable: true, get: function () { return get_location_info_1.location_to_string; } });
7
7
  var exupery_core_internals_1 = require("exupery-core-internals");
8
- Object.defineProperty(exports, "a", { enumerable: true, get: function () { return exupery_core_internals_1.array_literal; } });
8
+ Object.defineProperty(exports, "a", { enumerable: true, get: function () { return exupery_core_internals_1.list_literal; } });
9
9
  Object.defineProperty(exports, "d", { enumerable: true, get: function () { return exupery_core_internals_1.dictionary_literal; } });
10
10
  Object.defineProperty(exports, "set", { enumerable: true, get: function () { return exupery_core_internals_1.set; } });
11
11
  Object.defineProperty(exports, "not_set", { enumerable: true, get: function () { return exupery_core_internals_1.not_set; } });
@@ -1,15 +1,14 @@
1
1
  import * as _et from 'exupery-core-types';
2
- import * as pt from 'exupery-core-types';
3
2
  export type Raw_Or_Normal_Dictionary<T> = {
4
3
  [key: string]: T;
5
- } | pt.Dictionary<T>;
6
- export type Raw_Or_Normal_Array<T> = T[] | pt.Array<T>;
4
+ } | _et.Dictionary<T>;
5
+ export type Raw_Or_Normal_List<T> = T[] | _et.List<T>;
7
6
  export type Raw_Dictionary<T> = {
8
7
  [key: string]: T;
9
8
  };
10
- export declare const to_raw_array: <T>($: pt.Array<T>) => readonly T[];
9
+ export declare const to_raw_array: <T>($: _et.List<T>) => readonly T[];
11
10
  export type Dictionary<T_D> = _et.Dictionary<T_D>;
12
- export type List<T_L> = _et.Array<T_L>;
11
+ export type List<T_L> = _et.List<T_L>;
13
12
  export declare const wrap_dictionary: <T>($: Raw_Or_Normal_Dictionary<T>) => Dictionary<T>;
14
- export declare const wrap_list: <T>($: Raw_Or_Normal_Array<T>) => List<T>;
13
+ export declare const wrap_list: <T>($: Raw_Or_Normal_List<T>) => List<T>;
15
14
  export declare const wrap_state_group: <T>($: T) => T;
@@ -29,7 +29,7 @@ const to_raw_array = ($) => $.__get_raw_copy();
29
29
  exports.to_raw_array = to_raw_array;
30
30
  const wrap_dictionary = ($) => {
31
31
  function is_normal($) {
32
- return $.deprecated_to_array !== undefined && typeof $.deprecated_to_array === "function";
32
+ return $.__get_number_of_entries !== undefined && typeof $.__get_number_of_entries === "function";
33
33
  }
34
34
  if (is_normal($)) {
35
35
  return $;
@@ -41,7 +41,7 @@ const wrap_dictionary = ($) => {
41
41
  exports.wrap_dictionary = wrap_dictionary;
42
42
  const wrap_list = ($) => {
43
43
  if ($ instanceof Array) {
44
- return _ei.array_literal($);
44
+ return _ei.list_literal($);
45
45
  }
46
46
  if (!($.__for_each instanceof Function)) {
47
47
  throw new Error("invalid input in 'wrap_list'");
@@ -1,10 +1,9 @@
1
1
  import * as _et from 'exupery-core-types';
2
- import * as pt from 'exupery-core-types';
3
2
  import { Source_Location } from "../get_location_info";
4
3
  export type Raw_Or_Normal_Dictionary<T> = {
5
4
  [key: string]: T;
6
- } | pt.Dictionary<T>;
7
- export type Raw_Or_Normal_Array<T> = T[] | pt.Array<T>;
5
+ } | _et.Dictionary<T>;
6
+ export type Raw_Or_Normal_Array<T> = T[] | _et.List<T>;
8
7
  export type Raw_Dictionary<T> = {
9
8
  [key: string]: T;
10
9
  };
@@ -16,7 +15,7 @@ export type Reference_To_Stacked_Dictionary_Entry<G_Source, T_Dictionary_Entry>
16
15
  readonly 'key': string;
17
16
  readonly 'location': G_Source;
18
17
  };
19
- export declare const to_raw_array: <T>($: pt.Array<T>) => readonly T[];
18
+ export declare const to_raw_array: <T>($: _et.List<T>) => readonly T[];
20
19
  export type Dictionary<G_Source, T_D> = {
21
20
  readonly 'dictionary': _et.Dictionary<{
22
21
  readonly 'entry': T_D;
@@ -25,7 +24,7 @@ export type Dictionary<G_Source, T_D> = {
25
24
  readonly 'location': G_Source;
26
25
  };
27
26
  export type List<G_Source, T_L> = {
28
- readonly 'list': _et.Array<{
27
+ readonly 'list': _et.List<{
29
28
  readonly 'element': T_L;
30
29
  readonly 'location': G_Source;
31
30
  }>;
@@ -32,7 +32,7 @@ exports.to_raw_array = to_raw_array;
32
32
  const wrap_dictionary = ($) => {
33
33
  const location = (0, get_location_info_1.get_location_info)(depth + 1);
34
34
  function is_normal($) {
35
- return $.deprecated_to_array !== undefined && typeof $.deprecated_to_array === "function";
35
+ return $.__get_number_of_entries !== undefined && typeof $.__get_number_of_entries === "function";
36
36
  }
37
37
  if (is_normal($)) {
38
38
  return {
@@ -57,7 +57,7 @@ exports.wrap_dictionary = wrap_dictionary;
57
57
  const wrap_list = ($) => {
58
58
  const location = (0, get_location_info_1.get_location_info)(depth + 1);
59
59
  const decorated = $ instanceof Array
60
- ? _ei.array_literal($)
60
+ ? _ei.list_literal($)
61
61
  : $;
62
62
  if (!(decorated.__for_each instanceof Function)) {
63
63
  throw new Error("invalid input in 'wrap_list'");
@@ -1,10 +1,9 @@
1
1
  import * as _et from 'exupery-core-types';
2
- import * as pt from 'exupery-core-types';
3
2
  import { Source_Location } from "../get_location_info";
4
3
  export type Raw_Or_Normal_Dictionary<T> = {
5
4
  [key: string]: T;
6
- } | pt.Dictionary<T>;
7
- export type Raw_Or_Normal_Array<T> = T[] | pt.Array<T>;
5
+ } | _et.Dictionary<T>;
6
+ export type Raw_Or_Normal_List<T> = T[] | _et.List<T>;
8
7
  export type Raw_Dictionary<T> = {
9
8
  [key: string]: T;
10
9
  };
@@ -16,7 +15,7 @@ export type Reference_To_Stacked_Dictionary_Entry<G_Source, T_Dictionary_Entry>
16
15
  readonly 'key': string;
17
16
  readonly 'location': G_Source;
18
17
  };
19
- export declare const to_raw_array: <T>($: pt.Array<T>) => readonly T[];
18
+ export declare const to_raw_array: <T>($: _et.List<T>) => readonly T[];
20
19
  export type Dictionary<G_Source, T_D> = {
21
20
  readonly 'dictionary': _et.Dictionary<{
22
21
  readonly 'entry': T_D;
@@ -25,14 +24,14 @@ export type Dictionary<G_Source, T_D> = {
25
24
  readonly 'location': G_Source;
26
25
  };
27
26
  export type List<G_Source, T_L> = {
28
- readonly 'list': _et.Array<{
27
+ readonly 'list': _et.List<{
29
28
  readonly 'element': T_L;
30
29
  readonly 'location': G_Source;
31
30
  }>;
32
31
  readonly 'location': G_Source;
33
32
  };
34
33
  export declare const wrap_dictionary: <T>($: Raw_Or_Normal_Dictionary<T>) => Dictionary<Source_Location, T>;
35
- export declare const wrap_list: <T>($: Raw_Or_Normal_Array<T>) => List<Source_Location, T>;
34
+ export declare const wrap_list: <T>($: Raw_Or_Normal_List<T>) => List<Source_Location, T>;
36
35
  export declare const wrap_state_group: <T>($: T) => {
37
36
  location: Source_Location;
38
37
  'state group': T;
@@ -32,7 +32,7 @@ exports.to_raw_array = to_raw_array;
32
32
  const wrap_dictionary = ($) => {
33
33
  const location = (0, get_location_info_1.get_location_info)(depth + 1);
34
34
  function is_normal($) {
35
- return $.deprecated_to_array !== undefined && typeof $.deprecated_to_array === "function";
35
+ return $.__get_number_of_entries !== undefined && typeof $.__get_number_of_entries === "function";
36
36
  }
37
37
  if (is_normal($)) {
38
38
  return {
@@ -57,7 +57,7 @@ exports.wrap_dictionary = wrap_dictionary;
57
57
  const wrap_list = ($) => {
58
58
  const location = (0, get_location_info_1.get_location_info)(depth + 1);
59
59
  const decorated = $ instanceof Array
60
- ? _ei.array_literal($)
60
+ ? _ei.list_literal($)
61
61
  : $;
62
62
  if (!(decorated.__for_each instanceof Function)) {
63
63
  throw new Error("invalid input in 'wrap_list'");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exupery-core-data",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "license": "ISC",
5
5
  "description": "the Exupery package used for building datasets",
6
6
  "author": "Corno",
@@ -18,14 +18,11 @@
18
18
  "files": [
19
19
  "dist"
20
20
  ],
21
- "devDependencies": {
22
- "@types/node": "^18.15.3"
23
- },
24
21
  "repository": {
25
22
  "type": "git",
26
23
  "url": "git+https://github.com/corno/exupery-core.git"
27
24
  },
28
25
  "dependencies": {
29
- "exupery-core-internals": "^0.3.0"
26
+ "exupery-core-internals": "^0.3.10"
30
27
  }
31
28
  }