pareto-core-shorthands 0.1.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.
@@ -0,0 +1,14 @@
1
+ import * as _pi from 'pareto-core-interface';
2
+ export type Raw_Or_Normal_Dictionary<T> = {
3
+ [key: string]: T;
4
+ } | _pi.Dictionary<T>;
5
+ export type Raw_Or_Normal_List<T> = T[] | _pi.List<T>;
6
+ export type Raw_Dictionary<T> = {
7
+ [key: string]: T;
8
+ };
9
+ export declare const to_raw_array: <T>($: _pi.List<T>) => readonly T[];
10
+ export type Dictionary<T_D> = _pi.Dictionary<T_D>;
11
+ export type List<T_L> = _pi.List<T_L>;
12
+ export declare const wrap_dictionary: <T>($: Raw_Or_Normal_Dictionary<T>) => Dictionary<T>;
13
+ export declare const wrap_list: <T>($: Raw_Or_Normal_List<T>) => List<T>;
14
+ export declare const wrap_state_group: <T>($: T) => T;
@@ -0,0 +1,55 @@
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.wrap_state_group = exports.wrap_list = exports.wrap_dictionary = exports.to_raw_array = void 0;
27
+ const _pint = __importStar(require("pareto-core-internals"));
28
+ const to_raw_array = ($) => $.__get_raw_copy();
29
+ exports.to_raw_array = to_raw_array;
30
+ const wrap_dictionary = ($) => {
31
+ function is_normal($) {
32
+ return $.get_number_of_entries !== undefined && typeof $.get_number_of_entries === "function";
33
+ }
34
+ if (is_normal($)) {
35
+ return $;
36
+ }
37
+ else {
38
+ return _pint.dictionary_literal($);
39
+ }
40
+ };
41
+ exports.wrap_dictionary = wrap_dictionary;
42
+ const wrap_list = ($) => {
43
+ if ($ instanceof Array) {
44
+ return _pint.list_literal($);
45
+ }
46
+ if (!($.__for_each instanceof Function)) {
47
+ throw new Error("invalid input in 'wrap_list'");
48
+ }
49
+ return $;
50
+ };
51
+ exports.wrap_list = wrap_list;
52
+ const wrap_state_group = ($) => {
53
+ return $;
54
+ };
55
+ exports.wrap_state_group = wrap_state_group;
@@ -0,0 +1,40 @@
1
+ import * as _pint from 'pareto-core-internals';
2
+ import * as _pi from 'pareto-core-interface';
3
+ export type Raw_Or_Normal_Dictionary<T> = {
4
+ [key: string]: T;
5
+ } | _pi.Dictionary<T>;
6
+ export type Raw_Or_Normal_List<T> = T[] | _pi.List<T>;
7
+ export type Raw_Dictionary<T> = {
8
+ [key: string]: T;
9
+ };
10
+ export type Reference_To_Normal_Dictionary_Entry<G_Source, T_Dictionary_Entry> = {
11
+ readonly 'key': string;
12
+ readonly 'location': G_Source;
13
+ };
14
+ export type Reference_To_Stacked_Dictionary_Entry<G_Source, T_Dictionary_Entry> = {
15
+ readonly 'key': string;
16
+ readonly 'location': G_Source;
17
+ };
18
+ export declare const to_raw_array: <T>($: _pi.List<T>) => readonly T[];
19
+ export type Dictionary<G_Source, T_D> = {
20
+ readonly 'dictionary': _pi.Dictionary<{
21
+ readonly 'entry': T_D;
22
+ readonly 'location': G_Source;
23
+ }>;
24
+ readonly 'location': G_Source;
25
+ };
26
+ export type List<G_Source, T_L> = {
27
+ readonly 'list': _pi.List<{
28
+ readonly 'element': T_L;
29
+ readonly 'location': G_Source;
30
+ }>;
31
+ readonly 'location': G_Source;
32
+ };
33
+ export declare const wrap_dictionary: <T>($: Raw_Or_Normal_Dictionary<T>) => Dictionary<_pint.Source_Location, T>;
34
+ export declare const wrap_list: <T>($: Raw_Or_Normal_List<T>) => List<_pint.Source_Location, T>;
35
+ export declare const wrap_state_group: <T>($: T) => {
36
+ location: _pint.Source_Location;
37
+ 'state group': T;
38
+ };
39
+ export declare const wrap_reference: <T>($: string) => Reference_To_Normal_Dictionary_Entry<_pint.Source_Location, T>;
40
+ export declare const wrap_stack_reference: <T>(name: string) => Reference_To_Stacked_Dictionary_Entry<_pint.Source_Location, T>;
@@ -0,0 +1,93 @@
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.wrap_stack_reference = exports.wrap_reference = exports.wrap_state_group = exports.wrap_list = exports.wrap_dictionary = exports.to_raw_array = void 0;
27
+ const _pint = __importStar(require("pareto-core-internals"));
28
+ const depth = 1;
29
+ const to_raw_array = ($) => $.__get_raw_copy();
30
+ exports.to_raw_array = to_raw_array;
31
+ const wrap_dictionary = ($) => {
32
+ const location = _pint.get_location_info(depth + 1);
33
+ function is_normal($) {
34
+ return $.get_number_of_entries !== undefined && typeof $.get_number_of_entries === "function";
35
+ }
36
+ if (is_normal($)) {
37
+ return {
38
+ 'location': location,
39
+ 'dictionary': $.map(($) => ({
40
+ 'location': location,
41
+ 'entry': $,
42
+ }))
43
+ };
44
+ }
45
+ else {
46
+ return {
47
+ 'location': location,
48
+ 'dictionary': _pint.dictionary_literal($).map(($) => ({
49
+ 'location': location,
50
+ 'entry': $,
51
+ }))
52
+ };
53
+ }
54
+ };
55
+ exports.wrap_dictionary = wrap_dictionary;
56
+ const wrap_list = ($) => {
57
+ const location = _pint.get_location_info(depth + 1);
58
+ const decorated = $ instanceof Array
59
+ ? _pint.list_literal($)
60
+ : $;
61
+ if (!(decorated.__for_each instanceof Function)) {
62
+ throw new Error("invalid input in 'wrap_list'");
63
+ }
64
+ return {
65
+ 'location': location,
66
+ 'list': decorated.map(($) => ({
67
+ 'location': location,
68
+ 'element': $,
69
+ }))
70
+ };
71
+ };
72
+ exports.wrap_list = wrap_list;
73
+ const wrap_state_group = ($) => {
74
+ return {
75
+ 'location': _pint.get_location_info(depth + 1),
76
+ 'state group': $,
77
+ };
78
+ };
79
+ exports.wrap_state_group = wrap_state_group;
80
+ const wrap_reference = ($) => {
81
+ return {
82
+ 'location': _pint.get_location_info(depth + 1),
83
+ 'key': $,
84
+ };
85
+ };
86
+ exports.wrap_reference = wrap_reference;
87
+ const wrap_stack_reference = (name) => {
88
+ return {
89
+ 'location': _pint.get_location_info(depth + 1),
90
+ 'key': name,
91
+ };
92
+ };
93
+ exports.wrap_stack_reference = wrap_stack_reference;
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "pareto-core-shorthands",
3
+ "version": "0.1.0",
4
+ "license": "ISC",
5
+ "description": "the pareto package used for building datasets",
6
+ "author": "Corno",
7
+ "keywords": [
8
+ "pareto",
9
+ "dataset",
10
+ "data"
11
+ ],
12
+ "homepage": "https://github.com/corno/pareto-core-shorthands#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/corno/pareto-core-shorthands/issues"
15
+ },
16
+ "main": "./dist/index.js",
17
+ "types": "dist/index.d.ts",
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/corno/pareto-core-shorthands.git"
24
+ },
25
+ "dependencies": {
26
+ "pareto-core-internals": "^0.24.6"
27
+ }
28
+ }