@breadstone/mosaik-elements 0.0.135 → 0.0.137

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/Index.d.ts CHANGED
@@ -13,4 +13,6 @@ export type { ICancelEventDetail } from './Events/Details/Interfaces/ICancelEven
13
13
  export type { IChangedEventDetail } from './Events/Details/Interfaces/IChangedEventDetail';
14
14
  export type { IErrorEventDetail } from './Events/Details/Interfaces/IErrorEventDetail';
15
15
  export type { IValueEventDetail } from './Events/Details/Interfaces/IValueEventDetail';
16
+ export { filterBy, filterByMemberPath } from './Utils/filterBy';
17
+ export { orderBy, orderByMemberPath } from './Utils/orderBy';
16
18
  //# sourceMappingURL=Index.d.ts.map
package/Index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Index.d.ts","sourceRoot":"","sources":["../src/Index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,YAAY,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAChF,YAAY,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,YAAY,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AACvE,YAAY,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AACjG,OAAO,EAAE,2BAA2B,EAAE,MAAM,gDAAgD,CAAC;AAC7F,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,YAAY,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAC7E,YAAY,EAAE,kBAAkB,EAAE,MAAM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/Index.js CHANGED
@@ -3,4 +3,7 @@ export { EventListenerSubscription } from './Events/EventListenerSubscription';
3
3
  export { HTMLElementEventEmitter } from './Events/Emitters/HTMLElementEventEmitter';
4
4
  export { PureEventEmitter } from './Events/Emitters/PureEventEmitter';
5
5
  export { isEventListenerSubscription } from './Events/Interfaces/IEventListenerSubscription';
6
+ // utils
7
+ export { filterBy, filterByMemberPath } from './Utils/filterBy';
8
+ export { orderBy, orderByMemberPath } from './Utils/orderBy';
6
9
  //# sourceMappingURL=Index.js.map
package/Index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Index.js","sourceRoot":"","sources":["../src/Index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAKtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,gDAAgD,CAAC"}
1
+ {"version":3,"file":"Index.js","sourceRoot":"","sources":["../src/Index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAKtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,gDAAgD,CAAC;AAQ7F,QAAQ;AACR,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { Paths } from 'type-fest';
2
+ /**
3
+ * Filters a list using a predicate function (like Array.prototype.filter).
4
+ *
5
+ * @param input Source array; `null`/`undefined` yields `[]`.
6
+ * @param predicate Test function `(item, index, array) => boolean`. Must be synchronous.
7
+ * @returns New filtered array (original is not mutated).
8
+ *
9
+ * @public
10
+ */
11
+ export declare function filterBy<T>(input: ReadonlyArray<T> | null | undefined, predicate: (item: T, index: number, array: ReadonlyArray<T>) => boolean): Array<T>;
12
+ /**
13
+ * Filters a list of items by checking one or multiple (dot-path) properties against a search term.
14
+ *
15
+ * - Case-insensitive string matching
16
+ * - Supports `string | number | boolean | string[]`
17
+ * - Strict (exact) vs. non-strict (substring) mode
18
+ * - Deep property access via dot notation ("user.profile.name")
19
+ * - Member paths are compile-time checked via TypeFest `Paths<T>`
20
+ *
21
+ * @param input The source array. `null`/`undefined` yields an empty list.
22
+ * @param props Property paths (dot-notation, type-checked) to check against the search term(s).
23
+ * @param search A search term or a list of terms. Non-string terms are stringified.
24
+ * @param strict If `true`, matches must be exact (case-insensitive for strings). Otherwise substring matching is used.
25
+ * @returns A new filtered array (original is not mutated).
26
+ *
27
+ * @public
28
+ */
29
+ export declare function filterByMemberPath<T>(input: ReadonlyArray<T> | null | undefined, props: ReadonlyArray<Paths<T>>, search?: string | number | boolean | ReadonlyArray<string>, strict?: boolean): Array<T>;
30
+ //# sourceMappingURL=filterBy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filterBy.d.ts","sourceRoot":"","sources":["../../src/Utils/filterBy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAIvC;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACtB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,EAC1C,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,OAAO,GACxE,KAAK,CAAC,CAAC,CAAC,CASV;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAChC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,EAC1C,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAC9B,MAAM,GAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,aAAa,CAAC,MAAM,CAAM,EAC9D,MAAM,GAAE,OAAe,GACxB,KAAK,CAAC,CAAC,CAAC,CAgEV"}
@@ -0,0 +1,124 @@
1
+ // libs/mosaik-elements/src/Utils/filterBy.ts
2
+ // #region Imports
3
+ // #endregion
4
+ /**
5
+ * Filters a list using a predicate function (like Array.prototype.filter).
6
+ *
7
+ * @param input Source array; `null`/`undefined` yields `[]`.
8
+ * @param predicate Test function `(item, index, array) => boolean`. Must be synchronous.
9
+ * @returns New filtered array (original is not mutated).
10
+ *
11
+ * @public
12
+ */
13
+ export function filterBy(input, predicate) {
14
+ const list = Array.isArray(input) ? input : [];
15
+ if (typeof predicate !== 'function') {
16
+ return [...list];
17
+ }
18
+ // Mirrors Array.prototype.filter semantics.
19
+ // Reference: MDN Array.prototype.filter. [oai_citation:3‡MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter?utm_source=chatgpt.com)
20
+ return list.filter((item, index, array) => predicate(item, index, array));
21
+ }
22
+ /**
23
+ * Filters a list of items by checking one or multiple (dot-path) properties against a search term.
24
+ *
25
+ * - Case-insensitive string matching
26
+ * - Supports `string | number | boolean | string[]`
27
+ * - Strict (exact) vs. non-strict (substring) mode
28
+ * - Deep property access via dot notation ("user.profile.name")
29
+ * - Member paths are compile-time checked via TypeFest `Paths<T>`
30
+ *
31
+ * @param input The source array. `null`/`undefined` yields an empty list.
32
+ * @param props Property paths (dot-notation, type-checked) to check against the search term(s).
33
+ * @param search A search term or a list of terms. Non-string terms are stringified.
34
+ * @param strict If `true`, matches must be exact (case-insensitive for strings). Otherwise substring matching is used.
35
+ * @returns A new filtered array (original is not mutated).
36
+ *
37
+ * @public
38
+ */
39
+ export function filterByMemberPath(input, props, search = '', strict = false) {
40
+ const list = Array.isArray(input) ? input : [];
41
+ if (!props.length) {
42
+ return [...list];
43
+ }
44
+ const validType = typeof search === 'string' ||
45
+ typeof search === 'number' ||
46
+ typeof search === 'boolean' ||
47
+ Array.isArray(search);
48
+ if (!validType) {
49
+ return [...list];
50
+ }
51
+ const isArraySearch = Array.isArray(search);
52
+ const terms = isArraySearch
53
+ ? search.map((s) => s.toLowerCase())
54
+ : [String(search).toLowerCase()];
55
+ // Historical behavior: empty string means "no filter"
56
+ if (!isArraySearch && terms[0] === '') {
57
+ return [...list];
58
+ }
59
+ return list.filter((item) => props.some((path) => {
60
+ // `Paths<T>` from type-fest is a template-literal string union; cast is safe for runtime usage.
61
+ const value = getByPath(item, path);
62
+ if (value === null || value === undefined) {
63
+ return false;
64
+ }
65
+ // Support primitive or array-of-primitive values. If an array, match if ANY element satisfies the criteria.
66
+ if (Array.isArray(value)) {
67
+ const lowered = value
68
+ .filter((v) => v !== null && v !== undefined && (typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean'))
69
+ .map((v) => String(v).toLowerCase());
70
+ if (!lowered.length) {
71
+ return false;
72
+ }
73
+ if (isArraySearch) {
74
+ return strict
75
+ ? lowered.some((lv) => terms.includes(lv))
76
+ : lowered.some((lv) => terms.some((t) => lv.includes(t)));
77
+ }
78
+ return strict ? lowered.includes(terms[0]) : lowered.some((lv) => lv.includes(terms[0]));
79
+ }
80
+ // Skip plain objects to avoid meaningless "[object Object]" stringification.
81
+ if (typeof value === 'object') {
82
+ return false;
83
+ }
84
+ // includes() is case-sensitive; normalize both sides for case-insensitive contains. [oai_citation:4‡MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes?utm_source=chatgpt.com)
85
+ if (typeof value !== 'string' && typeof value !== 'number' && typeof value !== 'boolean') {
86
+ return false; // Non-primitive (e.g., symbol) is ignored
87
+ }
88
+ const normalized = String(value).toLowerCase();
89
+ return isArraySearch
90
+ ? terms.some((t) => strict ? normalized === t : normalized.includes(t))
91
+ : strict
92
+ ? normalized === terms[0]
93
+ : normalized.includes(terms[0]);
94
+ }));
95
+ }
96
+ /**
97
+ * Safely reads a deep property value from an object using a dot-separated path.
98
+ *
99
+ * Example:
100
+ * getByPath({ a: { b: 1 } }, "a.b") => 1
101
+ *
102
+ * Returns `undefined` if the chain breaks.
103
+ * See MDN for filter semantics referenced above. [oai_citation:5‡MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter?utm_source=chatgpt.com)
104
+ *
105
+ * @internal
106
+ */
107
+ function getByPath(obj, path) {
108
+ if (!path) {
109
+ return undefined;
110
+ }
111
+ const parts = path.split('.');
112
+ let cursor = obj;
113
+ for (const key of parts) {
114
+ if (cursor !== null && typeof cursor === 'object' && key in cursor) {
115
+ cursor = cursor[key];
116
+ }
117
+ else {
118
+ return undefined;
119
+ }
120
+ }
121
+ return cursor;
122
+ }
123
+ // #endregion
124
+ //# sourceMappingURL=filterBy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filterBy.js","sourceRoot":"","sources":["../../src/Utils/filterBy.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,kBAAkB;AAIlB,aAAa;AAEb;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CACpB,KAA0C,EAC1C,SAAuE;IAEvE,MAAM,IAAI,GAAqB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IACjE,IAAI,OAAO,SAAS,KAAK,UAAU,EA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K,EAAE,CAAC;QACtB,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,GAAG,IAAK,MAAkC,EAAE,CAAC;YAC9F,MAAM,GAAI,MAAkC,CAAC,GAAG,CAAC,CAAC;QACtD,CAAC;aAAM,CAAC;YACJ,OAAO,SAAS,CAAC;QACrB,CAAC;IACL,CAAC;IAED,OAAO,MAA6B,CAAC;AACzC,CAAC;AAED,aAAa"}
@@ -0,0 +1,26 @@
1
+ import type { Paths } from 'type-fest';
2
+ type Direction = 'asc' | 'desc';
3
+ /**
4
+ * Orders a list by one or multiple selector functions (iteratees).
5
+ *
6
+ * @public
7
+ * @param input Source array; `null`/`undefined` yields `[]`.
8
+ * @param selectors Single selector or list of selectors `(item) => key`.
9
+ * @param direction `'asc' | 'desc'` or list thereof aligned to `selectors`. Defaults to `'asc'`.
10
+ * @param collator Optional `Intl.Collator` for locale-aware string comparison.
11
+ * @returns New sorted array (original is not mutated).
12
+ */
13
+ export declare function orderBy<T>(input: ReadonlyArray<T> | null | undefined, selectors?: ((item: T) => unknown) | ReadonlyArray<(item: T) => unknown>, direction?: Direction | ReadonlyArray<Direction>, collator?: Intl.Collator): Array<T>;
14
+ /**
15
+ * Orders a list by one or multiple member paths (string-based, deep paths) with compile-time path safety via `type-fest`'s `Paths<T>`.
16
+ *
17
+ * @public
18
+ * @param input Source array; `null`/`undefined` yields `[]`.
19
+ * @param paths Single path or list of paths (`Paths<T>`).
20
+ * @param direction `'asc' | 'desc'` or list thereof aligned to `paths`. Defaults to `'asc'`.
21
+ * @param collator Optional `Intl.Collator` for locale-aware string comparison.
22
+ * @returns New sorted array (original is not mutated).
23
+ */
24
+ export declare function orderByMemberPath<T>(input: ReadonlyArray<T> | null | undefined, paths?: Paths<T> | ReadonlyArray<Paths<T>>, direction?: Direction | ReadonlyArray<Direction>, collator?: Intl.Collator): Array<T>;
25
+ export {};
26
+ //# sourceMappingURL=orderBy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orderBy.d.ts","sourceRoot":"","sources":["../../src/Utils/orderBy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAIvC,KAAK,SAAS,GAAG,KAAK,GAAG,MAAM,CAAC;AAEhC;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,GAAG,aAAa,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,EAAE,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CA0BrO;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,EAAE,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAyBjN"}
@@ -0,0 +1,135 @@
1
+ // #region Imports
2
+ /**
3
+ * Orders a list by one or multiple selector functions (iteratees).
4
+ *
5
+ * @public
6
+ * @param input Source array; `null`/`undefined` yields `[]`.
7
+ * @param selectors Single selector or list of selectors `(item) => key`.
8
+ * @param direction `'asc' | 'desc'` or list thereof aligned to `selectors`. Defaults to `'asc'`.
9
+ * @param collator Optional `Intl.Collator` for locale-aware string comparison.
10
+ * @returns New sorted array (original is not mutated).
11
+ */
12
+ export function orderBy(input, selectors, direction, collator) {
13
+ const list = Array.isArray(input) ? [...input] : [];
14
+ if (!selectors || (Array.isArray(selectors) && selectors.length === 0)) {
15
+ return list.sort((a, b) => baseCompare(String(a), String(b), collator));
16
+ }
17
+ const iteratees = typeof selectors === 'function' ? [selectors] : selectors;
18
+ const directions = Array.isArray(direction)
19
+ ? direction.length === iteratees.length ? direction : Array(iteratees.length).fill(direction[0] ?? 'asc')
20
+ : Array(iteratees.length).fill(direction ?? 'asc');
21
+ return list.sort((a, b) => {
22
+ for (let i = 0; i < iteratees.length; i += 1) {
23
+ const asc = directions[i] !== 'desc';
24
+ const av = iteratees[i](a);
25
+ const bv = iteratees[i](b);
26
+ const cmp = baseCompare(av, bv, collator);
27
+ if (cmp !== 0) {
28
+ return asc ? cmp : -cmp;
29
+ }
30
+ }
31
+ return 0;
32
+ });
33
+ }
34
+ /**
35
+ * Orders a list by one or multiple member paths (string-based, deep paths) with compile-time path safety via `type-fest`'s `Paths<T>`.
36
+ *
37
+ * @public
38
+ * @param input Source array; `null`/`undefined` yields `[]`.
39
+ * @param paths Single path or list of paths (`Paths<T>`).
40
+ * @param direction `'asc' | 'desc'` or list thereof aligned to `paths`. Defaults to `'asc'`.
41
+ * @param collator Optional `Intl.Collator` for locale-aware string comparison.
42
+ * @returns New sorted array (original is not mutated).
43
+ */
44
+ export function orderByMemberPath(input, paths, direction, collator) {
45
+ const list = Array.isArray(input) ? [...input] : [];
46
+ if (!paths || (Array.isArray(paths) && paths.length === 0)) {
47
+ return list.sort((a, b) => baseCompare(String(a), String(b), collator));
48
+ }
49
+ const pathList = Array.isArray(paths) ? paths : [paths];
50
+ const directions = Array.isArray(direction)
51
+ ? direction.length === pathList.length ? direction : Array(pathList.length).fill(direction[0] ?? 'asc')
52
+ : Array(pathList.length).fill(direction ?? 'asc');
53
+ return list.sort((a, b) => {
54
+ for (let i = 0; i < pathList.length; i += 1) {
55
+ const asc = directions[i] !== 'desc';
56
+ const av = getByPath(a, pathList[i]);
57
+ const bv = getByPath(b, pathList[i]);
58
+ const cmp = baseCompare(av, bv, collator);
59
+ if (cmp !== 0) {
60
+ return asc ? cmp : -cmp;
61
+ }
62
+ }
63
+ return 0;
64
+ });
65
+ }
66
+ /**
67
+ * Compares two values in a strict, predictable manner.
68
+ * Rules:
69
+ * - `null`/`undefined` come first
70
+ * - `Date` compared by epoch time
71
+ * - numbers/booleans compared numerically
72
+ * - strings compared case-insensitively or with the provided `Intl.Collator`
73
+ */
74
+ function baseCompare(a, b, collator) {
75
+ const aNil = a === null || a === undefined;
76
+ const bNil = b === null || b === undefined;
77
+ if (aNil && bNil) {
78
+ return 0;
79
+ }
80
+ if (aNil) {
81
+ return -1;
82
+ }
83
+ if (bNil) {
84
+ return 1;
85
+ }
86
+ if (a instanceof Date || b instanceof Date) {
87
+ const ta = a instanceof Date ? a.getTime() : Number(a);
88
+ const tb = b instanceof Date ? b.getTime() : Number(b);
89
+ if (ta < tb) {
90
+ return -1;
91
+ }
92
+ if (ta > tb) {
93
+ return 1;
94
+ }
95
+ return 0;
96
+ }
97
+ if (typeof a === 'number' ||
98
+ typeof b === 'number' ||
99
+ typeof a === 'boolean' ||
100
+ typeof b === 'boolean') {
101
+ const na = Number(a);
102
+ const nb = Number(b);
103
+ if (na < nb) {
104
+ return -1;
105
+ }
106
+ if (na > nb) {
107
+ return 1;
108
+ }
109
+ return 0;
110
+ }
111
+ const sa = String(a);
112
+ const sb = String(b);
113
+ return collator ? collator.compare(sa, sb) : sa.toLowerCase().localeCompare(sb.toLowerCase());
114
+ }
115
+ /**
116
+ * Reads a deep property via dot-separated path (e.g., "user.profile.lastName").
117
+ * Returns `undefined` if the path cannot be fully resolved.
118
+ */
119
+ function getByPath(obj, path) {
120
+ if (!path) {
121
+ return undefined;
122
+ }
123
+ const segments = path.split('.');
124
+ let cursor = obj;
125
+ for (const key of segments) {
126
+ if (cursor !== null && typeof cursor === 'object' && key in cursor) {
127
+ cursor = cursor[key];
128
+ }
129
+ else {
130
+ return undefined;
131
+ }
132
+ }
133
+ return cursor;
134
+ }
135
+ //# sourceMappingURL=orderBy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orderBy.js","sourceRoot":"","sources":["../../src/Utils/orderBy.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAQlB;;;;;;;;;GASG;AACH,MAAM,UAAU,OAAO,CAAI,KAA0C,EAAE,SAAwE,EAAE,SAAgD,EAAE,QAAwB;IACvN,MAAM,IAAI,GAAa,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAE9D,IAAI,CAAC,SAAS,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;QACrE,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAI,EAAE,CAAI,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;IAClF,CAAC;IAED,MAAM,SAAS,GACX,OAAO,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE9D,MAAM,UAAU,GAA6B,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;QACjE,CAAC,CAAC,SAAS,CAAC,MAAM,KAAK,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC;QACzG,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC,CAAC;IAEvD,OAAO,IAAI,CAAC,IAAI,CAA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3B,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC;YAAC,OAAO,CAAC,CAAC;QAAC,CAAC;QAC1B,OAAO,CAAC,CAAC;IACb,CAAC;IAED,MAAM,EAAE,GAAW,MAAM,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,EAAE,GAAW,MAAM,CAAC,CAAC,CAAC,CAAC;IAC7B,OAAO,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;AAClG,CAAC;AAED;;;GAGG;AACH,SAAS,SAAS,CAAoB,GAAW,EAAE,IAAY;IAC3D,IAAI,CAAC,IAAI,EAAE,CAAC;QACR,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,MAAM,QAAQ,GAAkB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChD,IAAI,MAAM,GAAY,GAAc,CAAC;IAErC,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QACzB,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,GAAG,IAAK,MAAkC,EAAE,CAAC;YAC9F,MAAM,GAAI,MAAkC,CAAC,GAAG,CAAC,CAAC;QACtD,CAAC;aAAM,CAAC;YACJ,OAAO,SAAS,CAAC;QACrB,CAAC;IACL,CAAC;IAED,OAAO,MAA6B,CAAC;AACzC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@breadstone/mosaik-elements",
3
- "version": "0.0.135",
3
+ "version": "0.0.137",
4
4
  "description": "Mosaik element core package.",
5
5
  "license": "MIT",
6
6
  "author": "andre.wehlert <awehlert@breadstone.de> (https://www.breadstone.de)",