pareto-core-shorthands 0.1.8 → 0.1.10

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.
@@ -3,12 +3,13 @@ export declare namespace optional {
3
3
  const set: typeof import("pareto-core-internals/dist/target/optional/set").$$;
4
4
  const not_set: typeof import("pareto-core-internals/dist/target/optional/not_set").$$;
5
5
  }
6
- export type Raw_Dictionary<T> = {
6
+ export type Raw_Or_Normal_Dictionary<T> = {
7
7
  [key: string]: T;
8
- };
9
- export type Raw_List<T> = 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_Dictionary<T>) => Dictionary<T>;
13
- export declare const wrap_list: <T>($: T[]) => List<T>;
14
- export declare const wrap_state_group: <T>($: T) => T;
8
+ } | _pi.Dictionary<T>;
9
+ export type Raw_Or_Normal_List<T> = T[] | _pi.List<T>;
10
+ export declare namespace dictionnary {
11
+ const literal: <T>($: Raw_Or_Normal_Dictionary<T>) => _pi.Dictionary<T>;
12
+ }
13
+ export declare namespace list {
14
+ const literal: <T>($: Raw_Or_Normal_List<T>) => _pi.List<T>;
15
+ }
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.wrap_state_group = exports.wrap_list = exports.wrap_dictionary = exports.optional = void 0;
26
+ exports.list = exports.dictionnary = exports.optional = void 0;
27
27
  const _pinternals = __importStar(require("pareto-core-internals/dist/literal"));
28
28
  var optional;
29
29
  (function (optional) {
@@ -31,14 +31,30 @@ var optional;
31
31
  optional.not_set = _pinternals.optional.not_set;
32
32
  })(optional || (exports.optional = optional = {}));
33
33
  const wrap_dictionary = ($) => {
34
- return _pinternals.dictionary.literal($);
34
+ function is_normal($) {
35
+ return $.__get_number_of_entries !== undefined && typeof $.__get_number_of_entries === "function";
36
+ }
37
+ if (is_normal($)) {
38
+ return $;
39
+ }
40
+ else {
41
+ return _pinternals.dictionary.literal($);
42
+ }
35
43
  };
36
- exports.wrap_dictionary = wrap_dictionary;
37
44
  const wrap_list = ($) => {
38
- return _pinternals.list.literal($);
39
- };
40
- exports.wrap_list = wrap_list;
41
- const wrap_state_group = ($) => {
45
+ if ($ instanceof Array) {
46
+ return _pinternals.list.literal($);
47
+ }
48
+ if (!($.__for_each instanceof Function)) {
49
+ throw new Error("invalid input in 'wrap_list'");
50
+ }
42
51
  return $;
43
52
  };
44
- exports.wrap_state_group = wrap_state_group;
53
+ var dictionnary;
54
+ (function (dictionnary) {
55
+ dictionnary.literal = wrap_dictionary;
56
+ })(dictionnary || (exports.dictionnary = dictionnary = {}));
57
+ var list;
58
+ (function (list) {
59
+ list.literal = wrap_list;
60
+ })(list || (exports.list = list = {}));
@@ -1,8 +1,8 @@
1
1
  import * as _pi from 'pareto-core-interface';
2
- export type Raw_Dictionary<T> = {
2
+ export type Raw_Or_Normal_Dictionary<T> = {
3
3
  [key: string]: T;
4
- };
5
- export type Raw_List<T> = T[];
4
+ } | _pi.Dictionary<T>;
5
+ export type Raw_Or_Normal_List<T> = T[] | _pi.List<T>;
6
6
  export type Reference_To_Normal_Dictionary_Entry<G_Source, T_Dictionary_Entry> = {
7
7
  readonly 'key': string;
8
8
  readonly 'location': G_Source;
@@ -29,8 +29,8 @@ export declare namespace optional {
29
29
  const set: typeof import("pareto-core-internals/dist/target/optional/set").$$;
30
30
  const not_set: typeof import("pareto-core-internals/dist/target/optional/not_set").$$;
31
31
  }
32
- export declare const wrap_dictionary: <T>($: Raw_Dictionary<T>) => Dictionary<_pi.Deprecated_Source_Location, T>;
33
- export declare const wrap_list: <T>($: Raw_List<T>) => List<_pi.Deprecated_Source_Location, T>;
32
+ export declare const wrap_dictionary: <T>($: Raw_Or_Normal_Dictionary<T>) => Dictionary<_pi.Deprecated_Source_Location, T>;
33
+ export declare const wrap_list: <T>($: Raw_Or_Normal_List<T>) => List<_pi.Deprecated_Source_Location, T>;
34
34
  export declare const wrap_state_group: <T>($: T) => {
35
35
  location: _pi.Deprecated_Source_Location;
36
36
  'state group': T;
@@ -35,20 +35,40 @@ var optional;
35
35
  })(optional || (exports.optional = optional = {}));
36
36
  const wrap_dictionary = ($) => {
37
37
  const location = (0, get_location_info_1.$$)(depth + 1);
38
- return {
39
- 'location': location,
40
- 'dictionary': _pinternals.dictionary.literal($).map(($) => ({
38
+ function is_normal($) {
39
+ return $.__get_number_of_entries !== undefined && typeof $.__get_number_of_entries === "function";
40
+ }
41
+ if (is_normal($)) {
42
+ return {
41
43
  'location': location,
42
- 'entry': $,
43
- }))
44
- };
44
+ 'dictionary': $.map(($) => ({
45
+ 'location': location,
46
+ 'entry': $,
47
+ }))
48
+ };
49
+ }
50
+ else {
51
+ return {
52
+ 'location': location,
53
+ 'dictionary': _pinternals.dictionary.literal($).map(($) => ({
54
+ 'location': location,
55
+ 'entry': $,
56
+ }))
57
+ };
58
+ }
45
59
  };
46
60
  exports.wrap_dictionary = wrap_dictionary;
47
61
  const wrap_list = ($) => {
48
62
  const location = (0, get_location_info_1.$$)(depth + 1);
63
+ const decorated = $ instanceof Array
64
+ ? _pinternals.list.literal($)
65
+ : $;
66
+ if (!(decorated.__for_each instanceof Function)) {
67
+ throw new Error("invalid input in 'wrap_list'");
68
+ }
49
69
  return {
50
70
  'location': location,
51
- 'list': _pinternals.list.literal($).map(($) => ({
71
+ 'list': decorated.map(($) => ({
52
72
  'location': location,
53
73
  'element': $,
54
74
  }))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pareto-core-shorthands",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "license": "ISC",
5
5
  "description": "the pareto package used for building datasets",
6
6
  "author": "Corno",
@@ -23,6 +23,6 @@
23
23
  "url": "git+https://github.com/corno/pareto-core-shorthands.git"
24
24
  },
25
25
  "dependencies": {
26
- "pareto-core-internals": "^0.24.24"
26
+ "pareto-core-internals": "^0.24.28"
27
27
  }
28
28
  }