exupery-core-data 0.1.10 → 0.2.0
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/get_location_info.d.ts +13 -0
- package/dist/get_location_info.js +57 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -7
- package/dist/shorthands/unresolved_data.d.ts +6 -6
- package/dist/shorthands/unresolved_data.js +6 -5
- package/dist/shorthands/unresolved_transformation.d.ts +6 -6
- package/dist/shorthands/unresolved_transformation.js +6 -5
- package/package.json +2 -2
|
@@ -0,0 +1,13 @@
|
|
|
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;
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
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
|
+
/**
|
|
36
|
+
* provides the source location (filepath and line number) of the source code file where this function is called,
|
|
37
|
+
* or if the depth is bigger than 0, the source location of the function at that stack depth
|
|
38
|
+
* @param depth
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
function get_location_info(depth) {
|
|
42
|
+
//we create an error, not to be thrown but to be disected for its stack
|
|
43
|
+
const e = new Error(); //don't move this statement to another function, it will change the depth of its stack
|
|
44
|
+
const line = get_line(e, depth);
|
|
45
|
+
const split = line.split(":");
|
|
46
|
+
if (split.length !== 3) {
|
|
47
|
+
throw new Error(`UNEXPECTED LOCATION FORMAT (CHECK THE DEPTH PARAMETER): ${line} (Expected 'file:line:column')`);
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
'file': split[0],
|
|
51
|
+
'line': Number(split[1]),
|
|
52
|
+
'column': Number(split[2]),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function location_to_string(location) {
|
|
56
|
+
return `${location.file}:${location.line}:${location.column}`;
|
|
57
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { get_location_info, location_to_string, Source_Location, } from "
|
|
1
|
+
export { get_location_info, location_to_string, Source_Location, } from "./get_location_info";
|
|
2
2
|
export { array_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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.not_set = exports.set = exports.d = exports.a = exports.location_to_string = exports.get_location_info = void 0;
|
|
4
|
+
var get_location_info_1 = require("./get_location_info");
|
|
5
|
+
Object.defineProperty(exports, "get_location_info", { enumerable: true, get: function () { return get_location_info_1.get_location_info; } });
|
|
6
|
+
Object.defineProperty(exports, "location_to_string", { enumerable: true, get: function () { return get_location_info_1.location_to_string; } });
|
|
4
7
|
var exupery_core_internals_1 = require("exupery-core-internals");
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
Object.defineProperty(exports, "
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(exports, "
|
|
9
|
-
Object.defineProperty(exports, "d", { enumerable: true, get: function () { return exupery_core_internals_2.dictionary_literal; } });
|
|
10
|
-
Object.defineProperty(exports, "set", { enumerable: true, get: function () { return exupery_core_internals_2.set; } });
|
|
11
|
-
Object.defineProperty(exports, "not_set", { enumerable: true, get: function () { return exupery_core_internals_2.not_set; } });
|
|
8
|
+
Object.defineProperty(exports, "a", { enumerable: true, get: function () { return exupery_core_internals_1.array_literal; } });
|
|
9
|
+
Object.defineProperty(exports, "d", { enumerable: true, get: function () { return exupery_core_internals_1.dictionary_literal; } });
|
|
10
|
+
Object.defineProperty(exports, "set", { enumerable: true, get: function () { return exupery_core_internals_1.set; } });
|
|
11
|
+
Object.defineProperty(exports, "not_set", { enumerable: true, get: function () { return exupery_core_internals_1.not_set; } });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as _ei from 'exupery-core-internals';
|
|
2
1
|
import * as _et from 'exupery-core-types';
|
|
3
2
|
import * as pt from 'exupery-core-types';
|
|
3
|
+
import { Source_Location } from "../get_location_info";
|
|
4
4
|
export type Raw_Or_Normal_Dictionary<T> = {
|
|
5
5
|
[key: string]: T;
|
|
6
6
|
} | pt.Dictionary<T>;
|
|
@@ -31,11 +31,11 @@ export type List<G_Source, T_L> = {
|
|
|
31
31
|
}>;
|
|
32
32
|
readonly 'location': G_Source;
|
|
33
33
|
};
|
|
34
|
-
export declare const wrap_dictionary: <T>($: Raw_Or_Normal_Dictionary<T>) => Dictionary<
|
|
35
|
-
export declare const wrap_list: <T>($: Raw_Or_Normal_Array<T>) => List<
|
|
34
|
+
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>;
|
|
36
36
|
export declare const wrap_state_group: <T>($: T) => {
|
|
37
|
-
location:
|
|
37
|
+
location: Source_Location;
|
|
38
38
|
'state group': T;
|
|
39
39
|
};
|
|
40
|
-
export declare const wrap_reference: <T>($: string) => Reference_To_Normal_Dictionary_Entry<
|
|
41
|
-
export declare const wrap_stack_reference: <T>(name: string) => Reference_To_Stacked_Dictionary_Entry<
|
|
40
|
+
export declare const wrap_reference: <T>($: string) => Reference_To_Normal_Dictionary_Entry<Source_Location, T>;
|
|
41
|
+
export declare const wrap_stack_reference: <T>(name: string) => Reference_To_Stacked_Dictionary_Entry<Source_Location, T>;
|
|
@@ -25,11 +25,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.wrap_stack_reference = exports.wrap_reference = exports.wrap_state_group = exports.wrap_list = exports.wrap_dictionary = exports.to_raw_array = void 0;
|
|
27
27
|
const _ei = __importStar(require("exupery-core-internals"));
|
|
28
|
+
const get_location_info_1 = require("../get_location_info");
|
|
28
29
|
const depth = 1;
|
|
29
30
|
const to_raw_array = ($) => $.__get_raw_copy();
|
|
30
31
|
exports.to_raw_array = to_raw_array;
|
|
31
32
|
const wrap_dictionary = ($) => {
|
|
32
|
-
const location =
|
|
33
|
+
const location = (0, get_location_info_1.get_location_info)(depth + 1);
|
|
33
34
|
function is_normal($) {
|
|
34
35
|
return $.to_array !== undefined && typeof $.to_array === "function";
|
|
35
36
|
}
|
|
@@ -54,7 +55,7 @@ const wrap_dictionary = ($) => {
|
|
|
54
55
|
};
|
|
55
56
|
exports.wrap_dictionary = wrap_dictionary;
|
|
56
57
|
const wrap_list = ($) => {
|
|
57
|
-
const location =
|
|
58
|
+
const location = (0, get_location_info_1.get_location_info)(depth + 1);
|
|
58
59
|
const decorated = $ instanceof Array
|
|
59
60
|
? _ei.array_literal($)
|
|
60
61
|
: $;
|
|
@@ -72,21 +73,21 @@ const wrap_list = ($) => {
|
|
|
72
73
|
exports.wrap_list = wrap_list;
|
|
73
74
|
const wrap_state_group = ($) => {
|
|
74
75
|
return {
|
|
75
|
-
'location':
|
|
76
|
+
'location': (0, get_location_info_1.get_location_info)(depth + 1),
|
|
76
77
|
'state group': $,
|
|
77
78
|
};
|
|
78
79
|
};
|
|
79
80
|
exports.wrap_state_group = wrap_state_group;
|
|
80
81
|
const wrap_reference = ($) => {
|
|
81
82
|
return {
|
|
82
|
-
'location':
|
|
83
|
+
'location': (0, get_location_info_1.get_location_info)(depth + 1),
|
|
83
84
|
'key': $,
|
|
84
85
|
};
|
|
85
86
|
};
|
|
86
87
|
exports.wrap_reference = wrap_reference;
|
|
87
88
|
const wrap_stack_reference = (name) => {
|
|
88
89
|
return {
|
|
89
|
-
'location':
|
|
90
|
+
'location': (0, get_location_info_1.get_location_info)(depth + 1),
|
|
90
91
|
'key': name,
|
|
91
92
|
};
|
|
92
93
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as _ei from 'exupery-core-internals';
|
|
2
1
|
import * as _et from 'exupery-core-types';
|
|
3
2
|
import * as pt from 'exupery-core-types';
|
|
3
|
+
import { Source_Location } from "../get_location_info";
|
|
4
4
|
export type Raw_Or_Normal_Dictionary<T> = {
|
|
5
5
|
[key: string]: T;
|
|
6
6
|
} | pt.Dictionary<T>;
|
|
@@ -31,11 +31,11 @@ export type List<G_Source, T_L> = {
|
|
|
31
31
|
}>;
|
|
32
32
|
readonly 'location': G_Source;
|
|
33
33
|
};
|
|
34
|
-
export declare const wrap_dictionary: <T>($: Raw_Or_Normal_Dictionary<T>) => Dictionary<
|
|
35
|
-
export declare const wrap_list: <T>($: Raw_Or_Normal_Array<T>) => List<
|
|
34
|
+
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>;
|
|
36
36
|
export declare const wrap_state_group: <T>($: T) => {
|
|
37
|
-
location:
|
|
37
|
+
location: Source_Location;
|
|
38
38
|
'state group': T;
|
|
39
39
|
};
|
|
40
|
-
export declare const wrap_reference: <T>($: string) => Reference_To_Normal_Dictionary_Entry<
|
|
41
|
-
export declare const wrap_stack_reference: <T>(name: string) => Reference_To_Stacked_Dictionary_Entry<
|
|
40
|
+
export declare const wrap_reference: <T>($: string) => Reference_To_Normal_Dictionary_Entry<Source_Location, T>;
|
|
41
|
+
export declare const wrap_stack_reference: <T>(name: string) => Reference_To_Stacked_Dictionary_Entry<Source_Location, T>;
|
|
@@ -25,11 +25,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.wrap_stack_reference = exports.wrap_reference = exports.wrap_state_group = exports.wrap_list = exports.wrap_dictionary = exports.to_raw_array = void 0;
|
|
27
27
|
const _ei = __importStar(require("exupery-core-internals"));
|
|
28
|
+
const get_location_info_1 = require("../get_location_info");
|
|
28
29
|
const depth = 0;
|
|
29
30
|
const to_raw_array = ($) => $.__get_raw_copy();
|
|
30
31
|
exports.to_raw_array = to_raw_array;
|
|
31
32
|
const wrap_dictionary = ($) => {
|
|
32
|
-
const location =
|
|
33
|
+
const location = (0, get_location_info_1.get_location_info)(depth + 1);
|
|
33
34
|
function is_normal($) {
|
|
34
35
|
return $.to_array !== undefined && typeof $.to_array === "function";
|
|
35
36
|
}
|
|
@@ -54,7 +55,7 @@ const wrap_dictionary = ($) => {
|
|
|
54
55
|
};
|
|
55
56
|
exports.wrap_dictionary = wrap_dictionary;
|
|
56
57
|
const wrap_list = ($) => {
|
|
57
|
-
const location =
|
|
58
|
+
const location = (0, get_location_info_1.get_location_info)(depth + 1);
|
|
58
59
|
const decorated = $ instanceof Array
|
|
59
60
|
? _ei.array_literal($)
|
|
60
61
|
: $;
|
|
@@ -72,21 +73,21 @@ const wrap_list = ($) => {
|
|
|
72
73
|
exports.wrap_list = wrap_list;
|
|
73
74
|
const wrap_state_group = ($) => {
|
|
74
75
|
return {
|
|
75
|
-
'location':
|
|
76
|
+
'location': (0, get_location_info_1.get_location_info)(depth + 1),
|
|
76
77
|
'state group': $,
|
|
77
78
|
};
|
|
78
79
|
};
|
|
79
80
|
exports.wrap_state_group = wrap_state_group;
|
|
80
81
|
const wrap_reference = ($) => {
|
|
81
82
|
return {
|
|
82
|
-
'location':
|
|
83
|
+
'location': (0, get_location_info_1.get_location_info)(depth + 1),
|
|
83
84
|
'key': $,
|
|
84
85
|
};
|
|
85
86
|
};
|
|
86
87
|
exports.wrap_reference = wrap_reference;
|
|
87
88
|
const wrap_stack_reference = (name) => {
|
|
88
89
|
return {
|
|
89
|
-
'location':
|
|
90
|
+
'location': (0, get_location_info_1.get_location_info)(depth + 1),
|
|
90
91
|
'key': name,
|
|
91
92
|
};
|
|
92
93
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "exupery-core-data",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"description": "the Exupery package used for building datasets",
|
|
6
6
|
"author": "Corno",
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
"url": "git+https://github.com/corno/exupery-core.git"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"exupery-core-internals": "^0.
|
|
29
|
+
"exupery-core-internals": "^0.2.0"
|
|
30
30
|
}
|
|
31
31
|
}
|