@k37z3r/jbase 2.0.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/LICENSE +621 -0
- package/README.md +124 -0
- package/dist/browser.d.ts +30 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +29 -0
- package/dist/browser.js.map +1 -0
- package/dist/core.d.ts +42 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +78 -0
- package/dist/core.js.map +1 -0
- package/dist/index.cjs +2150 -0
- package/dist/index.d.ts +1158 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +100 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2118 -0
- package/dist/jbase.browser.js +1906 -0
- package/dist/jbase.js +1898 -0
- package/dist/jbase.min.js +9 -0
- package/dist/modules/css/classes.d.ts +61 -0
- package/dist/modules/css/classes.d.ts.map +1 -0
- package/dist/modules/css/classes.js +88 -0
- package/dist/modules/css/classes.js.map +1 -0
- package/dist/modules/css/index.d.ts +30 -0
- package/dist/modules/css/index.d.ts.map +1 -0
- package/dist/modules/css/index.js +33 -0
- package/dist/modules/css/index.js.map +1 -0
- package/dist/modules/css/styles.d.ts +31 -0
- package/dist/modules/css/styles.d.ts.map +1 -0
- package/dist/modules/css/styles.js +49 -0
- package/dist/modules/css/styles.js.map +1 -0
- package/dist/modules/data/arrays.d.ts +131 -0
- package/dist/modules/data/arrays.d.ts.map +1 -0
- package/dist/modules/data/arrays.js +177 -0
- package/dist/modules/data/arrays.js.map +1 -0
- package/dist/modules/data/index.d.ts +29 -0
- package/dist/modules/data/index.d.ts.map +1 -0
- package/dist/modules/data/index.js +33 -0
- package/dist/modules/data/index.js.map +1 -0
- package/dist/modules/data/objects.d.ts +108 -0
- package/dist/modules/data/objects.d.ts.map +1 -0
- package/dist/modules/data/objects.js +168 -0
- package/dist/modules/data/objects.js.map +1 -0
- package/dist/modules/data/types.d.ts +35 -0
- package/dist/modules/data/types.d.ts.map +1 -0
- package/dist/modules/data/types.js +43 -0
- package/dist/modules/data/types.js.map +1 -0
- package/dist/modules/dom/attributes.d.ts +42 -0
- package/dist/modules/dom/attributes.d.ts.map +1 -0
- package/dist/modules/dom/attributes.js +69 -0
- package/dist/modules/dom/attributes.js.map +1 -0
- package/dist/modules/dom/content.d.ts +39 -0
- package/dist/modules/dom/content.d.ts.map +1 -0
- package/dist/modules/dom/content.js +63 -0
- package/dist/modules/dom/content.js.map +1 -0
- package/dist/modules/dom/index.d.ts +78 -0
- package/dist/modules/dom/index.d.ts.map +1 -0
- package/dist/modules/dom/index.js +48 -0
- package/dist/modules/dom/index.js.map +1 -0
- package/dist/modules/dom/manipulation.d.ts +159 -0
- package/dist/modules/dom/manipulation.d.ts.map +1 -0
- package/dist/modules/dom/manipulation.js +343 -0
- package/dist/modules/dom/manipulation.js.map +1 -0
- package/dist/modules/dom/states.d.ts +50 -0
- package/dist/modules/dom/states.d.ts.map +1 -0
- package/dist/modules/dom/states.js +89 -0
- package/dist/modules/dom/states.js.map +1 -0
- package/dist/modules/dom/traversal.d.ts +246 -0
- package/dist/modules/dom/traversal.d.ts.map +1 -0
- package/dist/modules/dom/traversal.js +527 -0
- package/dist/modules/dom/traversal.js.map +1 -0
- package/dist/modules/effects/fade.d.ts +58 -0
- package/dist/modules/effects/fade.d.ts.map +1 -0
- package/dist/modules/effects/fade.js +104 -0
- package/dist/modules/effects/fade.js.map +1 -0
- package/dist/modules/effects/index.d.ts +40 -0
- package/dist/modules/effects/index.d.ts.map +1 -0
- package/dist/modules/effects/index.js +38 -0
- package/dist/modules/effects/index.js.map +1 -0
- package/dist/modules/effects/slide.d.ts +58 -0
- package/dist/modules/effects/slide.d.ts.map +1 -0
- package/dist/modules/effects/slide.js +103 -0
- package/dist/modules/effects/slide.js.map +1 -0
- package/dist/modules/effects/vertical.d.ts +58 -0
- package/dist/modules/effects/vertical.d.ts.map +1 -0
- package/dist/modules/effects/vertical.js +118 -0
- package/dist/modules/effects/vertical.js.map +1 -0
- package/dist/modules/events/binding.d.ts +47 -0
- package/dist/modules/events/binding.d.ts.map +1 -0
- package/dist/modules/events/binding.js +60 -0
- package/dist/modules/events/binding.js.map +1 -0
- package/dist/modules/events/form.d.ts +72 -0
- package/dist/modules/events/form.d.ts.map +1 -0
- package/dist/modules/events/form.js +106 -0
- package/dist/modules/events/form.js.map +1 -0
- package/dist/modules/events/index.d.ts +62 -0
- package/dist/modules/events/index.d.ts.map +1 -0
- package/dist/modules/events/index.js +53 -0
- package/dist/modules/events/index.js.map +1 -0
- package/dist/modules/events/keyboard.d.ts +65 -0
- package/dist/modules/events/keyboard.d.ts.map +1 -0
- package/dist/modules/events/keyboard.js +83 -0
- package/dist/modules/events/keyboard.js.map +1 -0
- package/dist/modules/events/lifecycle.d.ts +28 -0
- package/dist/modules/events/lifecycle.d.ts.map +1 -0
- package/dist/modules/events/lifecycle.js +40 -0
- package/dist/modules/events/lifecycle.js.map +1 -0
- package/dist/modules/events/mouse.d.ts +120 -0
- package/dist/modules/events/mouse.d.ts.map +1 -0
- package/dist/modules/events/mouse.js +172 -0
- package/dist/modules/events/mouse.js.map +1 -0
- package/dist/modules/events/touch.d.ts +61 -0
- package/dist/modules/events/touch.d.ts.map +1 -0
- package/dist/modules/events/touch.js +74 -0
- package/dist/modules/events/touch.js.map +1 -0
- package/dist/modules/http/get.d.ts +47 -0
- package/dist/modules/http/get.d.ts.map +1 -0
- package/dist/modules/http/get.js +65 -0
- package/dist/modules/http/get.js.map +1 -0
- package/dist/modules/http/index.d.ts +37 -0
- package/dist/modules/http/index.d.ts.map +1 -0
- package/dist/modules/http/index.js +42 -0
- package/dist/modules/http/index.js.map +1 -0
- package/dist/modules/http/post.d.ts +36 -0
- package/dist/modules/http/post.d.ts.map +1 -0
- package/dist/modules/http/post.js +54 -0
- package/dist/modules/http/post.js.map +1 -0
- package/dist/types.d.ts +61 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +15 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +51 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +71 -0
- package/dist/utils.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file src/modules/data/arrays.ts
|
|
4
|
+
* @version 2.0.0
|
|
5
|
+
* @since 2.0.0
|
|
6
|
+
* @license GPL-3.0-or-later
|
|
7
|
+
* @copyright Sven Minio 2026
|
|
8
|
+
* @author Sven Minio <https://sven-minio.de>
|
|
9
|
+
* @category Data
|
|
10
|
+
* @description
|
|
11
|
+
* * 🇬🇧: Utility functions for array manipulation and data processing.
|
|
12
|
+
* * 🇩🇪: Hilfsfunktionen für Array-Manipulation und Datenverarbeitung.
|
|
13
|
+
* @requires ./types
|
|
14
|
+
* * 🇬🇧: Depends on match logic and types.
|
|
15
|
+
* * 🇩🇪: Hängt von Match-Logik und Typen ab.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.find = exports.remove = void 0;
|
|
19
|
+
exports.chunk = chunk;
|
|
20
|
+
exports.merge = merge;
|
|
21
|
+
exports.add = add;
|
|
22
|
+
const types_1 = require("./types");
|
|
23
|
+
/**
|
|
24
|
+
* * 🇬🇧: Splits an array into smaller groups (chunks). Ideal for pagination or grid layouts.
|
|
25
|
+
* * 🇩🇪: Teilt ein Array in kleinere Gruppen (Chunks) auf. Ideal für Pagination oder Grid-Layouts.
|
|
26
|
+
* @example
|
|
27
|
+
* chunk([1, 2, 3, 4, 5], 2) // => [[1, 2], [3, 4], [5]]
|
|
28
|
+
* @param array
|
|
29
|
+
* * 🇬🇧: The source array.
|
|
30
|
+
* * 🇩🇪: Das Ursprungs-Array.
|
|
31
|
+
* @param size
|
|
32
|
+
* * 🇬🇧: The size of each chunk.
|
|
33
|
+
* * 🇩🇪: Die Größe jedes Chunks.
|
|
34
|
+
* @returns
|
|
35
|
+
* * 🇬🇧: An array of arrays.
|
|
36
|
+
* * 🇩🇪: Ein Array aus Arrays.
|
|
37
|
+
*/
|
|
38
|
+
function chunk(array, size) {
|
|
39
|
+
const chunks = [];
|
|
40
|
+
for (let i = 0; i < array.length; i += size) {
|
|
41
|
+
chunks.push(array.slice(i, i + size));
|
|
42
|
+
}
|
|
43
|
+
return chunks;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* * 🇬🇧: Merges multiple arrays into a single flat array.
|
|
47
|
+
* * 🇩🇪: Führt mehrere Arrays zu einem einzigen flachen Array zusammen.
|
|
48
|
+
* @param arrays
|
|
49
|
+
* * 🇬🇧: A list of arrays.
|
|
50
|
+
* * 🇩🇪: Eine Liste von Arrays.
|
|
51
|
+
* @returns
|
|
52
|
+
* * 🇬🇧: A new, merged array.
|
|
53
|
+
* * 🇩🇪: Ein neues, zusammengefügtes Array.
|
|
54
|
+
*/
|
|
55
|
+
function merge(...arrays) {
|
|
56
|
+
return [].concat(...arrays);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* * 🇬🇧: Safely adds an element at a specific position without mutating the original array (Immutable).
|
|
60
|
+
* * 🇩🇪: Fügt ein Element sicher an einer bestimmten Position hinzu, ohne das Original-Array zu mutieren (Immutable).
|
|
61
|
+
* @param array
|
|
62
|
+
* * 🇬🇧: The array.
|
|
63
|
+
* * 🇩🇪: Das Array.
|
|
64
|
+
* @param item
|
|
65
|
+
* * 🇬🇧: The item to add.
|
|
66
|
+
* * 🇩🇪: Das hinzuzufügende Element.
|
|
67
|
+
* @param index
|
|
68
|
+
* * 🇬🇧: The position (default: end). Negative values count from the back (-1 = before the last one).
|
|
69
|
+
* * 🇩🇪: Die Position (Standard: Ende). Negative Werte zählen von hinten (-1 = vor dem letzten).
|
|
70
|
+
* @returns
|
|
71
|
+
* * 🇬🇧: A new array including the element.
|
|
72
|
+
* * 🇩🇪: Ein neues Array inklusive dem Element.
|
|
73
|
+
*/
|
|
74
|
+
function add(array, item, index = array.length) {
|
|
75
|
+
const copy = [...array];
|
|
76
|
+
const idx = index < 0 ? array.length + index + 1 : index;
|
|
77
|
+
copy.splice(idx, 0, item);
|
|
78
|
+
return copy;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* * 🇬🇧: Removes elements based on index or match logic.
|
|
82
|
+
* * 🇩🇪: Entfernt Elemente basierend auf Index oder Match-Logik.
|
|
83
|
+
*/
|
|
84
|
+
exports.remove = {
|
|
85
|
+
/**
|
|
86
|
+
* * 🇬🇧: Removes an element at a specific index.
|
|
87
|
+
* * 🇩🇪: Entfernt ein Element an einem spezifischen Index.
|
|
88
|
+
* @param array
|
|
89
|
+
* * 🇬🇧: The array.
|
|
90
|
+
* * 🇩🇪: Das Array.
|
|
91
|
+
* @param index
|
|
92
|
+
* * 🇬🇧: The index (negative values allowed).
|
|
93
|
+
* * 🇩🇪: Der Index (negativ möglich).
|
|
94
|
+
*/
|
|
95
|
+
at(array, index) {
|
|
96
|
+
const copy = [...array];
|
|
97
|
+
const idx = index < 0 ? array.length + index : index;
|
|
98
|
+
if (idx >= 0 && idx < copy.length) {
|
|
99
|
+
copy.splice(idx, 1);
|
|
100
|
+
}
|
|
101
|
+
return copy;
|
|
102
|
+
},
|
|
103
|
+
/**
|
|
104
|
+
* * 🇬🇧: Removes the first element.
|
|
105
|
+
* * 🇩🇪: Entfernt das erste Element.
|
|
106
|
+
*/
|
|
107
|
+
first(array) { return array.slice(1); },
|
|
108
|
+
/**
|
|
109
|
+
* * 🇬🇧: Removes the last element.
|
|
110
|
+
* * 🇩🇪: Entfernt das letzte Element.
|
|
111
|
+
*/
|
|
112
|
+
last(array) { return array.slice(0, -1); },
|
|
113
|
+
/**
|
|
114
|
+
* * 🇬🇧: Removes all elements matching a query condition.
|
|
115
|
+
* * 🇩🇪: Entfernt alle Elemente, die einer Suchbedingung entsprechen.
|
|
116
|
+
* @example
|
|
117
|
+
* remove.byMatch(users, 'Admin', 'exact', 'role')
|
|
118
|
+
* @param array
|
|
119
|
+
* * 🇬🇧: The array.
|
|
120
|
+
* * 🇩🇪: Das Array.
|
|
121
|
+
* @param query
|
|
122
|
+
* * 🇬🇧: The search query.
|
|
123
|
+
* * 🇩🇪: Der Suchbegriff.
|
|
124
|
+
* @param mode
|
|
125
|
+
* * 🇬🇧: The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
|
126
|
+
* * 🇩🇪: Der Vergleichsmodus ('exact', 'contains', 'startsWith', 'endsWith').
|
|
127
|
+
* @param key
|
|
128
|
+
* * 🇬🇧: (Optional) The object key if it is an array of objects.
|
|
129
|
+
* * 🇩🇪: (Optional) Der Objektschlüssel, falls es ein Array von Objekten ist.
|
|
130
|
+
*/
|
|
131
|
+
byMatch(array, query, mode = 'exact', key) {
|
|
132
|
+
return array.filter(item => {
|
|
133
|
+
const val = key ? item[key] : item;
|
|
134
|
+
return !(0, types_1.checkMatch)(val, query, mode);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* * 🇬🇧: Searches for elements in the array.
|
|
140
|
+
* * 🇩🇪: Sucht Elemente im Array.
|
|
141
|
+
*/
|
|
142
|
+
exports.find = {
|
|
143
|
+
/**
|
|
144
|
+
* * 🇬🇧: Finds the index of the first match.
|
|
145
|
+
* * 🇩🇪: Findet den Index des ersten Treffers.
|
|
146
|
+
* @returns
|
|
147
|
+
* * 🇬🇧: Index or -1.
|
|
148
|
+
* * 🇩🇪: Index oder -1.
|
|
149
|
+
*/
|
|
150
|
+
index(array, query, mode = 'exact', key) {
|
|
151
|
+
return array.findIndex(item => {
|
|
152
|
+
const val = key ? item[key] : item;
|
|
153
|
+
return (0, types_1.checkMatch)(val, query, mode);
|
|
154
|
+
});
|
|
155
|
+
},
|
|
156
|
+
/**
|
|
157
|
+
* * 🇬🇧: Returns all elements matching the condition (Filter).
|
|
158
|
+
* * 🇩🇪: Gibt alle Elemente zurück, die der Bedingung entsprechen (Filter).
|
|
159
|
+
*/
|
|
160
|
+
all(array, query, mode = 'exact', key) {
|
|
161
|
+
return array.filter(item => {
|
|
162
|
+
const val = key ? item[key] : item;
|
|
163
|
+
return (0, types_1.checkMatch)(val, query, mode);
|
|
164
|
+
});
|
|
165
|
+
},
|
|
166
|
+
/**
|
|
167
|
+
* * 🇬🇧: Returns the first matching element (or undefined).
|
|
168
|
+
* * 🇩🇪: Gibt das erste gefundene Element zurück (oder undefined).
|
|
169
|
+
*/
|
|
170
|
+
first(array, query, mode = 'exact', key) {
|
|
171
|
+
return array.find(item => {
|
|
172
|
+
const val = key ? item[key] : item;
|
|
173
|
+
return (0, types_1.checkMatch)(val, query, mode);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
//# sourceMappingURL=arrays.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrays.js","sourceRoot":"","sources":["../../../src/modules/data/arrays.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAmBH,sBAMC;AAYD,sBAEC;AAkBD,kBAKC;AA5DD,mCAAgD;AAEhD;;;;;;;;;;;;;;GAcG;AACH,SAAgB,KAAK,CAAI,KAAU,EAAE,IAAY;IAC7C,MAAM,MAAM,GAAU,EAAE,CAAC;IACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC;QAC1C,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,KAAK,CAAI,GAAG,MAAa;IACrC,OAAO,EAAE,CAAC,MAAM,CAAC,GAAI,MAAc,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,GAAG,CAAI,KAAU,EAAE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;IACP,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file src/modules/data/index.ts
|
|
3
|
+
* @version 2.0.0
|
|
4
|
+
* @since 2.0.0
|
|
5
|
+
* * @license GPL-3.0-or-later
|
|
6
|
+
* @copyright Sven Minio 2026
|
|
7
|
+
* @author Sven Minio <https://sven-minio.de>
|
|
8
|
+
* @category Data
|
|
9
|
+
* @description
|
|
10
|
+
* * 🇬🇧: Central entry point for data manipulation modules. Aggregates array and object utilities.
|
|
11
|
+
* * 🇩🇪: Zentraler Einstiegspunkt für Datenmanipulations-Module. Aggregiert Array- und Objekt-Hilfsmethoden.
|
|
12
|
+
* @requires ./arrays
|
|
13
|
+
* * 🇬🇧: Array manipulation methods.
|
|
14
|
+
* * 🇩🇪: Methoden zur Array-Manipulation.
|
|
15
|
+
* @requires ./objects
|
|
16
|
+
* * 🇬🇧: Object manipulation methods.
|
|
17
|
+
* * 🇩🇪: Methoden zur Objekt-Manipulation.
|
|
18
|
+
*/
|
|
19
|
+
import * as arrayMethods from './arrays';
|
|
20
|
+
import * as objectMethods from './objects';
|
|
21
|
+
/**
|
|
22
|
+
* * 🇬🇧: Central data utility object. Bundles array ('arr') and object ('obj') manipulation methods.
|
|
23
|
+
* * 🇩🇪: Zentrales Daten-Utility-Objekt. Bündelt Methoden zur Array- ('arr') und Objekt-Manipulation ('obj').
|
|
24
|
+
*/
|
|
25
|
+
export declare const data: {
|
|
26
|
+
arr: typeof arrayMethods;
|
|
27
|
+
obj: typeof objectMethods;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/data/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,YAAY,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,aAAa,MAAM,WAAW,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,IAAI;;;CAGhB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file src/modules/data/index.ts
|
|
4
|
+
* @version 2.0.0
|
|
5
|
+
* @since 2.0.0
|
|
6
|
+
* * @license GPL-3.0-or-later
|
|
7
|
+
* @copyright Sven Minio 2026
|
|
8
|
+
* @author Sven Minio <https://sven-minio.de>
|
|
9
|
+
* @category Data
|
|
10
|
+
* @description
|
|
11
|
+
* * 🇬🇧: Central entry point for data manipulation modules. Aggregates array and object utilities.
|
|
12
|
+
* * 🇩🇪: Zentraler Einstiegspunkt für Datenmanipulations-Module. Aggregiert Array- und Objekt-Hilfsmethoden.
|
|
13
|
+
* @requires ./arrays
|
|
14
|
+
* * 🇬🇧: Array manipulation methods.
|
|
15
|
+
* * 🇩🇪: Methoden zur Array-Manipulation.
|
|
16
|
+
* @requires ./objects
|
|
17
|
+
* * 🇬🇧: Object manipulation methods.
|
|
18
|
+
* * 🇩🇪: Methoden zur Objekt-Manipulation.
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.data = void 0;
|
|
22
|
+
const tslib_1 = require("tslib");
|
|
23
|
+
const arrayMethods = tslib_1.__importStar(require("./arrays"));
|
|
24
|
+
const objectMethods = tslib_1.__importStar(require("./objects"));
|
|
25
|
+
/**
|
|
26
|
+
* * 🇬🇧: Central data utility object. Bundles array ('arr') and object ('obj') manipulation methods.
|
|
27
|
+
* * 🇩🇪: Zentrales Daten-Utility-Objekt. Bündelt Methoden zur Array- ('arr') und Objekt-Manipulation ('obj').
|
|
28
|
+
*/
|
|
29
|
+
exports.data = {
|
|
30
|
+
arr: arrayMethods,
|
|
31
|
+
obj: objectMethods
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/data/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;AAEH,+DAAyC;AACzC,iEAA2C;AAE3C;;;GAGG;AACU,QAAA,IAAI,GAAG;IAChB,GAAG,EAAE,YAAY;IACjB,GAAG,EAAE,aAAa;CACrB,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file src/modules/data/objects.ts
|
|
3
|
+
* @version 2.0.0
|
|
4
|
+
* @since 2.0.0
|
|
5
|
+
* @license GPL-3.0-or-later
|
|
6
|
+
* @copyright Sven Minio 2026
|
|
7
|
+
* @author Sven Minio <https://sven-minio.de>
|
|
8
|
+
* @category Data
|
|
9
|
+
* @description
|
|
10
|
+
* * 🇬🇧: Utility functions for object manipulation (e.g., deep merging, extension).
|
|
11
|
+
* * 🇩🇪: Hilfsfunktionen für Objekt-Manipulation (z.B. Deep Merge, Erweiterung).
|
|
12
|
+
* @requires ./types
|
|
13
|
+
* * 🇬🇧: Depends on match logic and types.
|
|
14
|
+
* * 🇩🇪: Hängt von Match-Logik und Typen ab.
|
|
15
|
+
*/
|
|
16
|
+
import { MatchMode } from './types';
|
|
17
|
+
/**
|
|
18
|
+
* * 🇬🇧: Recursively merges multiple objects (Deep Merge).
|
|
19
|
+
* * 🇩🇪: Führt mehrere Objekte rekursiv zusammen (Deep Merge).
|
|
20
|
+
* @example
|
|
21
|
+
* merge({ a: 1, b: { x: 1 } }, { b: { y: 2 } }) // => { a: 1, b: { x: 1, y: 2 } }
|
|
22
|
+
* @param target
|
|
23
|
+
* * 🇬🇧: The target object (will be modified!).
|
|
24
|
+
* * 🇩🇪: Das Zielobjekt (wird modifiziert!).
|
|
25
|
+
* @param sources
|
|
26
|
+
* * 🇬🇧: One or more source objects.
|
|
27
|
+
* * 🇩🇪: Ein oder mehrere Quellobjekte.
|
|
28
|
+
* @returns
|
|
29
|
+
* * 🇬🇧: The modified target object.
|
|
30
|
+
* * 🇩🇪: Das modifizierte Zielobjekt.
|
|
31
|
+
*/
|
|
32
|
+
export declare function merge(target: any, ...sources: any[]): any;
|
|
33
|
+
/**
|
|
34
|
+
* * 🇬🇧: Creates a new object containing only the specified keys (Allowlist).
|
|
35
|
+
* * 🇩🇪: Erstellt ein neues Objekt, das nur die angegebenen Schlüssel enthält (Allowlist).
|
|
36
|
+
* @param obj
|
|
37
|
+
* * 🇬🇧: The source object.
|
|
38
|
+
* * 🇩🇪: Das Quellobjekt.
|
|
39
|
+
* @param keys
|
|
40
|
+
* * 🇬🇧: Array of keys to keep.
|
|
41
|
+
* * 🇩🇪: Array der Schlüssel, die übernommen werden sollen.
|
|
42
|
+
* @returns
|
|
43
|
+
* * 🇬🇧: A new object with selected keys.
|
|
44
|
+
* * 🇩🇪: Ein neues Objekt mit den gewählten Schlüsseln.
|
|
45
|
+
*/
|
|
46
|
+
export declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
47
|
+
/**
|
|
48
|
+
* * 🇬🇧: Creates a new object containing all keys EXCEPT the specified ones (Blocklist).
|
|
49
|
+
* * 🇩🇪: Erstellt ein neues Objekt, das alle Schlüssel enthält AUẞER den angegebenen (Blocklist).
|
|
50
|
+
* @param obj
|
|
51
|
+
* * 🇬🇧: The source object.
|
|
52
|
+
* * 🇩🇪: Das Quellobjekt.
|
|
53
|
+
* @param keys
|
|
54
|
+
* * 🇬🇧: Array of keys to remove.
|
|
55
|
+
* * 🇩🇪: Array der Schlüssel, die entfernt werden sollen.
|
|
56
|
+
* @returns
|
|
57
|
+
* * 🇬🇧: A new object without the specified keys.
|
|
58
|
+
* * 🇩🇪: Ein neues Objekt ohne die angegebenen Schlüssel.
|
|
59
|
+
*/
|
|
60
|
+
export declare function omit<T, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
|
61
|
+
/**
|
|
62
|
+
* * 🇬🇧: Safely retrieves a value from a nested object (Safe Navigation).
|
|
63
|
+
* * 🇩🇪: Liest einen Wert aus einem verschachtelten Objekt sicher aus (Safe Navigation).
|
|
64
|
+
* @example
|
|
65
|
+
* get(user, 'address.city') // Returns city or undefined
|
|
66
|
+
* @param obj
|
|
67
|
+
* * 🇬🇧: The object.
|
|
68
|
+
* * 🇩🇪: Das Objekt.
|
|
69
|
+
* @param path
|
|
70
|
+
* * 🇬🇧: The path as a dot-notation string.
|
|
71
|
+
* * 🇩🇪: Der Pfad als String mit Punkt-Notation.
|
|
72
|
+
* @returns
|
|
73
|
+
* * 🇬🇧: The found value or undefined.
|
|
74
|
+
* * 🇩🇪: Der gefundene Wert oder undefined.
|
|
75
|
+
*/
|
|
76
|
+
export declare function get(obj: any, path: string): any;
|
|
77
|
+
/**
|
|
78
|
+
* * 🇬🇧: Sets a value deeply within a nested object. Creates missing intermediate objects automatically.
|
|
79
|
+
* * 🇩🇪: Setzt einen Wert tief in einem verschachtelten Objekt. Erstellt fehlende Zwischen-Objekte automatisch.
|
|
80
|
+
* @param obj
|
|
81
|
+
* * 🇬🇧: The object to modify.
|
|
82
|
+
* * 🇩🇪: Das zu modifizierende Objekt.
|
|
83
|
+
* @param path
|
|
84
|
+
* * 🇬🇧: The path as a string (e.g., 'settings.theme.color').
|
|
85
|
+
* * 🇩🇪: Der Pfad als String (z.B. 'settings.theme.color').
|
|
86
|
+
* @param value
|
|
87
|
+
* * 🇬🇧: The value to set.
|
|
88
|
+
* * 🇩🇪: Der zu setzende Wert.
|
|
89
|
+
*/
|
|
90
|
+
export declare function set(obj: any, path: string, value: any): void;
|
|
91
|
+
/**
|
|
92
|
+
* * 🇬🇧: Searches keys or values in the object.
|
|
93
|
+
* * 🇩🇪: Sucht Keys oder Values im Objekt.
|
|
94
|
+
*/
|
|
95
|
+
export declare const find: {
|
|
96
|
+
/**
|
|
97
|
+
* * 🇬🇧: Finds all keys matching the query.
|
|
98
|
+
* * 🇩🇪: Findet alle Schlüssel (Keys), die auf den Suchbegriff passen.
|
|
99
|
+
* @example find.key(config, 'api_', 'startsWith')
|
|
100
|
+
*/
|
|
101
|
+
key(obj: any, query: string, mode?: MatchMode): string[];
|
|
102
|
+
/**
|
|
103
|
+
* * 🇬🇧: Finds all values matching the query.
|
|
104
|
+
* * 🇩🇪: Findet alle Werte (Values), die auf den Suchbegriff passen.
|
|
105
|
+
*/
|
|
106
|
+
value(obj: any, query: string, mode?: MatchMode): any[];
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=objects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../../src/modules/data/objects.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,SAAS,EAAc,MAAM,SAAS,CAAC;AAEhD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE,GAAG,GAAG,CAgBzD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAMvF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAMxE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,CAE/C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAS5D;AAED;;;GAGG;AACH,eAAO,MAAM,IAAI;IACb;;;;OAIG;aACM,GAAG,SAAS,MAAM,SAAQ,SAAS,GAAa,MAAM,EAAE;IAIjE;;;OAGG;eACQ,GAAG,SAAS,MAAM,SAAQ,SAAS,GAAa,GAAG,EAAE;CAGnE,CAAC"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file src/modules/data/objects.ts
|
|
4
|
+
* @version 2.0.0
|
|
5
|
+
* @since 2.0.0
|
|
6
|
+
* @license GPL-3.0-or-later
|
|
7
|
+
* @copyright Sven Minio 2026
|
|
8
|
+
* @author Sven Minio <https://sven-minio.de>
|
|
9
|
+
* @category Data
|
|
10
|
+
* @description
|
|
11
|
+
* * 🇬🇧: Utility functions for object manipulation (e.g., deep merging, extension).
|
|
12
|
+
* * 🇩🇪: Hilfsfunktionen für Objekt-Manipulation (z.B. Deep Merge, Erweiterung).
|
|
13
|
+
* @requires ./types
|
|
14
|
+
* * 🇬🇧: Depends on match logic and types.
|
|
15
|
+
* * 🇩🇪: Hängt von Match-Logik und Typen ab.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.find = void 0;
|
|
19
|
+
exports.merge = merge;
|
|
20
|
+
exports.pick = pick;
|
|
21
|
+
exports.omit = omit;
|
|
22
|
+
exports.get = get;
|
|
23
|
+
exports.set = set;
|
|
24
|
+
const types_1 = require("./types");
|
|
25
|
+
/**
|
|
26
|
+
* * 🇬🇧: Recursively merges multiple objects (Deep Merge).
|
|
27
|
+
* * 🇩🇪: Führt mehrere Objekte rekursiv zusammen (Deep Merge).
|
|
28
|
+
* @example
|
|
29
|
+
* merge({ a: 1, b: { x: 1 } }, { b: { y: 2 } }) // => { a: 1, b: { x: 1, y: 2 } }
|
|
30
|
+
* @param target
|
|
31
|
+
* * 🇬🇧: The target object (will be modified!).
|
|
32
|
+
* * 🇩🇪: Das Zielobjekt (wird modifiziert!).
|
|
33
|
+
* @param sources
|
|
34
|
+
* * 🇬🇧: One or more source objects.
|
|
35
|
+
* * 🇩🇪: Ein oder mehrere Quellobjekte.
|
|
36
|
+
* @returns
|
|
37
|
+
* * 🇬🇧: The modified target object.
|
|
38
|
+
* * 🇩🇪: Das modifizierte Zielobjekt.
|
|
39
|
+
*/
|
|
40
|
+
function merge(target, ...sources) {
|
|
41
|
+
if (!sources.length)
|
|
42
|
+
return target;
|
|
43
|
+
const source = sources.shift();
|
|
44
|
+
if (isObject(target) && isObject(source)) {
|
|
45
|
+
for (const key in source) {
|
|
46
|
+
if (key === '__proto__' || key === 'constructor')
|
|
47
|
+
continue;
|
|
48
|
+
if (isObject(source[key])) {
|
|
49
|
+
if (!target[key])
|
|
50
|
+
Object.assign(target, { [key]: {} });
|
|
51
|
+
merge(target[key], source[key]);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
Object.assign(target, { [key]: source[key] });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return merge(target, ...sources);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* * 🇬🇧: Creates a new object containing only the specified keys (Allowlist).
|
|
62
|
+
* * 🇩🇪: Erstellt ein neues Objekt, das nur die angegebenen Schlüssel enthält (Allowlist).
|
|
63
|
+
* @param obj
|
|
64
|
+
* * 🇬🇧: The source object.
|
|
65
|
+
* * 🇩🇪: Das Quellobjekt.
|
|
66
|
+
* @param keys
|
|
67
|
+
* * 🇬🇧: Array of keys to keep.
|
|
68
|
+
* * 🇩🇪: Array der Schlüssel, die übernommen werden sollen.
|
|
69
|
+
* @returns
|
|
70
|
+
* * 🇬🇧: A new object with selected keys.
|
|
71
|
+
* * 🇩🇪: Ein neues Objekt mit den gewählten Schlüsseln.
|
|
72
|
+
*/
|
|
73
|
+
function pick(obj, keys) {
|
|
74
|
+
const ret = {};
|
|
75
|
+
keys.forEach(key => {
|
|
76
|
+
if (key in obj)
|
|
77
|
+
ret[key] = obj[key];
|
|
78
|
+
});
|
|
79
|
+
return ret;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* * 🇬🇧: Creates a new object containing all keys EXCEPT the specified ones (Blocklist).
|
|
83
|
+
* * 🇩🇪: Erstellt ein neues Objekt, das alle Schlüssel enthält AUẞER den angegebenen (Blocklist).
|
|
84
|
+
* @param obj
|
|
85
|
+
* * 🇬🇧: The source object.
|
|
86
|
+
* * 🇩🇪: Das Quellobjekt.
|
|
87
|
+
* @param keys
|
|
88
|
+
* * 🇬🇧: Array of keys to remove.
|
|
89
|
+
* * 🇩🇪: Array der Schlüssel, die entfernt werden sollen.
|
|
90
|
+
* @returns
|
|
91
|
+
* * 🇬🇧: A new object without the specified keys.
|
|
92
|
+
* * 🇩🇪: Ein neues Objekt ohne die angegebenen Schlüssel.
|
|
93
|
+
*/
|
|
94
|
+
function omit(obj, keys) {
|
|
95
|
+
const ret = { ...obj };
|
|
96
|
+
keys.forEach(key => {
|
|
97
|
+
delete ret[key];
|
|
98
|
+
});
|
|
99
|
+
return ret;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* * 🇬🇧: Safely retrieves a value from a nested object (Safe Navigation).
|
|
103
|
+
* * 🇩🇪: Liest einen Wert aus einem verschachtelten Objekt sicher aus (Safe Navigation).
|
|
104
|
+
* @example
|
|
105
|
+
* get(user, 'address.city') // Returns city or undefined
|
|
106
|
+
* @param obj
|
|
107
|
+
* * 🇬🇧: The object.
|
|
108
|
+
* * 🇩🇪: Das Objekt.
|
|
109
|
+
* @param path
|
|
110
|
+
* * 🇬🇧: The path as a dot-notation string.
|
|
111
|
+
* * 🇩🇪: Der Pfad als String mit Punkt-Notation.
|
|
112
|
+
* @returns
|
|
113
|
+
* * 🇬🇧: The found value or undefined.
|
|
114
|
+
* * 🇩🇪: Der gefundene Wert oder undefined.
|
|
115
|
+
*/
|
|
116
|
+
function get(obj, path) {
|
|
117
|
+
return path.split('.').reduce((acc, part) => acc && acc[part], obj);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* * 🇬🇧: Sets a value deeply within a nested object. Creates missing intermediate objects automatically.
|
|
121
|
+
* * 🇩🇪: Setzt einen Wert tief in einem verschachtelten Objekt. Erstellt fehlende Zwischen-Objekte automatisch.
|
|
122
|
+
* @param obj
|
|
123
|
+
* * 🇬🇧: The object to modify.
|
|
124
|
+
* * 🇩🇪: Das zu modifizierende Objekt.
|
|
125
|
+
* @param path
|
|
126
|
+
* * 🇬🇧: The path as a string (e.g., 'settings.theme.color').
|
|
127
|
+
* * 🇩🇪: Der Pfad als String (z.B. 'settings.theme.color').
|
|
128
|
+
* @param value
|
|
129
|
+
* * 🇬🇧: The value to set.
|
|
130
|
+
* * 🇩🇪: Der zu setzende Wert.
|
|
131
|
+
*/
|
|
132
|
+
function set(obj, path, value) {
|
|
133
|
+
const parts = path.split('.');
|
|
134
|
+
let current = obj;
|
|
135
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
136
|
+
const part = parts[i];
|
|
137
|
+
if (!current[part])
|
|
138
|
+
current[part] = {};
|
|
139
|
+
current = current[part];
|
|
140
|
+
}
|
|
141
|
+
current[parts[parts.length - 1]] = value;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* * 🇬🇧: Searches keys or values in the object.
|
|
145
|
+
* * 🇩🇪: Sucht Keys oder Values im Objekt.
|
|
146
|
+
*/
|
|
147
|
+
exports.find = {
|
|
148
|
+
/**
|
|
149
|
+
* * 🇬🇧: Finds all keys matching the query.
|
|
150
|
+
* * 🇩🇪: Findet alle Schlüssel (Keys), die auf den Suchbegriff passen.
|
|
151
|
+
* @example find.key(config, 'api_', 'startsWith')
|
|
152
|
+
*/
|
|
153
|
+
key(obj, query, mode = 'exact') {
|
|
154
|
+
return Object.keys(obj).filter(key => (0, types_1.checkMatch)(key, query, mode));
|
|
155
|
+
},
|
|
156
|
+
/**
|
|
157
|
+
* * 🇬🇧: Finds all values matching the query.
|
|
158
|
+
* * 🇩🇪: Findet alle Werte (Values), die auf den Suchbegriff passen.
|
|
159
|
+
*/
|
|
160
|
+
value(obj, query, mode = 'exact') {
|
|
161
|
+
return Object.values(obj).filter(val => (0, types_1.checkMatch)(val, query, mode));
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
// Helper
|
|
165
|
+
function isObject(item) {
|
|
166
|
+
return (item && typeof item === 'object' && !Array.isArray(item));
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=objects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objects.js","sourceRoot":"","sources":["../../../src/modules/data/objects.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAmBH,sBAgBC;AAeD,oBAMC;AAeD,oBAMC;AAiBD,kBAEC;AAeD,kBASC;AAtHD,mCAAgD;AAEhD;;;;;;;;;;;;;;GAcG;AACH,SAAgB,KAAK,CAAC,MAAW,EAAE,GAAG,OAAc;IAChD,IAAI,CAAC,OAAO,CAAC,MAAM;QAAE,OAAO,MAAM,CAAC;IACnC,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAE/B,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACvC,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YACvB,IAAI,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,aAAa;gBAAE,SAAS;YAC3D,IAAI,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBACxB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;oBAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;gBACvD,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC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
+
* @version 2.0.0
|
|
4
|
+
* @since 2.0.0
|
|
5
|
+
* @license GPL-3.0-or-later
|
|
6
|
+
* @copyright Sven Minio 2026
|
|
7
|
+
* @author Sven Minio <https://sven-minio.de>
|
|
8
|
+
* @category Data
|
|
9
|
+
* @description
|
|
10
|
+
* * 🇬🇧: Type definitions and validation helpers for data structures.
|
|
11
|
+
* * 🇩🇪: Typ-Definitionen und Validierungs-Hilfsmittel für Datenstrukturen.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* * 🇬🇧: Defines the matching modes for search operations.
|
|
15
|
+
* * 🇩🇪: Definiert die Vergleichsmodi für Suchoperationen.
|
|
16
|
+
*/
|
|
17
|
+
export type MatchMode = 'exact' | 'contains' | 'startsWith' | 'endsWith';
|
|
18
|
+
/**
|
|
19
|
+
* * 🇬🇧: Internal helper to compare values based on the specified mode. Converts values to strings and lowercase for comparison.
|
|
20
|
+
* * 🇩🇪: Interner Helfer zum Vergleichen von Werten basierend auf dem angegebenen Modus. Konvertiert Werte für den Vergleich in Strings und Kleinschreibung.
|
|
21
|
+
* @param value
|
|
22
|
+
* * 🇬🇧: The value to check.
|
|
23
|
+
* * 🇩🇪: Der zu prüfende Wert.
|
|
24
|
+
* @param query
|
|
25
|
+
* * 🇬🇧: The search query.
|
|
26
|
+
* * 🇩🇪: Der Suchbegriff.
|
|
27
|
+
* @param mode
|
|
28
|
+
* * 🇬🇧: The matching mode.
|
|
29
|
+
* * 🇩🇪: Der Vergleichsmodus.
|
|
30
|
+
* @returns
|
|
31
|
+
* * 🇬🇧: True if the value matches the query.
|
|
32
|
+
* * 🇩🇪: True, wenn der Wert mit der Query übereinstimmt.
|
|
33
|
+
*/
|
|
34
|
+
export declare function checkMatch(value: any, query: any, mode: MatchMode): boolean;
|
|
35
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/modules/data/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,YAAY,GAAG,UAAU,CAAC;AAEzE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAW3E"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file src/modules/data/types.ts
|
|
4
|
+
* @version 2.0.0
|
|
5
|
+
* @since 2.0.0
|
|
6
|
+
* @license GPL-3.0-or-later
|
|
7
|
+
* @copyright Sven Minio 2026
|
|
8
|
+
* @author Sven Minio <https://sven-minio.de>
|
|
9
|
+
* @category Data
|
|
10
|
+
* @description
|
|
11
|
+
* * 🇬🇧: Type definitions and validation helpers for data structures.
|
|
12
|
+
* * 🇩🇪: Typ-Definitionen und Validierungs-Hilfsmittel für Datenstrukturen.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.checkMatch = checkMatch;
|
|
16
|
+
/**
|
|
17
|
+
* * 🇬🇧: Internal helper to compare values based on the specified mode. Converts values to strings and lowercase for comparison.
|
|
18
|
+
* * 🇩🇪: Interner Helfer zum Vergleichen von Werten basierend auf dem angegebenen Modus. Konvertiert Werte für den Vergleich in Strings und Kleinschreibung.
|
|
19
|
+
* @param value
|
|
20
|
+
* * 🇬🇧: The value to check.
|
|
21
|
+
* * 🇩🇪: Der zu prüfende Wert.
|
|
22
|
+
* @param query
|
|
23
|
+
* * 🇬🇧: The search query.
|
|
24
|
+
* * 🇩🇪: Der Suchbegriff.
|
|
25
|
+
* @param mode
|
|
26
|
+
* * 🇬🇧: The matching mode.
|
|
27
|
+
* * 🇩🇪: Der Vergleichsmodus.
|
|
28
|
+
* @returns
|
|
29
|
+
* * 🇬🇧: True if the value matches the query.
|
|
30
|
+
* * 🇩🇪: True, wenn der Wert mit der Query übereinstimmt.
|
|
31
|
+
*/
|
|
32
|
+
function checkMatch(value, query, mode) {
|
|
33
|
+
const valStr = String(value).toLowerCase();
|
|
34
|
+
const queryStr = String(query).toLowerCase();
|
|
35
|
+
switch (mode) {
|
|
36
|
+
case 'exact': return valStr === queryStr;
|
|
37
|
+
case 'startsWith': return valStr.startsWith(queryStr);
|
|
38
|
+
case 'endsWith': return valStr.endsWith(queryStr);
|
|
39
|
+
case 'contains': return valStr.includes(queryStr);
|
|
40
|
+
default: return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/modules/data/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AAwBH,gCAWC;AA3BD;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,UAAU,CAAC,KAAU,EAAE,KAAU,EAAE,IAAe;IAC9D,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IAE7C,QAAQ,IAAI,EAAE,CAAC;QACX,KAAK,OAAO,CAAC,CAAC,OAAO,MAAM,KAAK,QAAQ,CAAC;QACzC,KAAK,YAAY,CAAC,CAAC,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QACtD,KAAK,UAAU,CAAC,CAAC,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAClD,KAAK,UAAU,CAAC,CAAC,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAClD,OAAO,CAAC,CAAC,OAAO,KAAK,CAAC;IAC1B,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file src/modules/dom/attributes.ts
|
|
3
|
+
* @version 2.0.0
|
|
4
|
+
* @since 2.0.0
|
|
5
|
+
* @license GPL-3.0-or-later
|
|
6
|
+
* @copyright Sven Minio 2026
|
|
7
|
+
* @author Sven Minio <https://sven-minio.de>
|
|
8
|
+
* @category DOM
|
|
9
|
+
* @description
|
|
10
|
+
* * 🇬🇧: Methods for getting and setting HTML attributes and properties (attr, data, val).
|
|
11
|
+
* * 🇩🇪: Methoden zum Lesen und Setzen von HTML-Attributen und Eigenschaften (attr, data, val).
|
|
12
|
+
* @requires ../../core
|
|
13
|
+
* * 🇬🇧: Depends on the core jBase class for type definitions.
|
|
14
|
+
* * 🇩🇪: Hängt von der Core-jBase-Klasse für Typ-Definitionen ab.
|
|
15
|
+
*/
|
|
16
|
+
import { jBase } from '../../core';
|
|
17
|
+
/**
|
|
18
|
+
* * 🇬🇧: Gets an attribute from the first element or sets it for all elements in the selection.
|
|
19
|
+
* * 🇩🇪: Liest ein Attribut vom ersten Element oder setzt es für alle Elemente in der Auswahl.
|
|
20
|
+
* @param name
|
|
21
|
+
* * 🇬🇧: The name of the attribute (e.g., 'href', 'data-id').
|
|
22
|
+
* * 🇩🇪: Der Name des Attributs (z.B. 'href', 'data-id').
|
|
23
|
+
* @param value
|
|
24
|
+
* * 🇬🇧: (Optional) The value to set. If undefined, acts as a getter.
|
|
25
|
+
* * 🇩🇪: (Optional) Der zu setzende Wert. Wenn nicht angegeben, wird gelesen.
|
|
26
|
+
* @returns
|
|
27
|
+
* * 🇬🇧: The attribute value (string/null) when reading, or the jBase instance when writing.
|
|
28
|
+
* * 🇩🇪: Beim Lesen: Der Wert des Attributs (string/null). Beim Schreiben: Die jBase-Instanz.
|
|
29
|
+
*/
|
|
30
|
+
export declare function attr(this: jBase, name: string, value?: string): string | null | jBase;
|
|
31
|
+
/**
|
|
32
|
+
* * 🇬🇧: Gets the 'value' from the first form element or sets it for all elements. Supports Input, Textarea, and Select elements.
|
|
33
|
+
* * 🇩🇪: Liest den 'value' vom ersten Formularelement oder setzt ihn für alle Elemente. Unterstützt Input-, Textarea- und Select-Elemente.
|
|
34
|
+
* @param value
|
|
35
|
+
* * 🇬🇧: (Optional) The value to set. If undefined, acts as a getter.
|
|
36
|
+
* * 🇩🇪: (Optional) Der zu setzende Wert. Wenn nicht angegeben, wird gelesen.
|
|
37
|
+
* @returns
|
|
38
|
+
* * 🇬🇧: The current value as a string when reading, or the jBase instance when writing.
|
|
39
|
+
* * 🇩🇪: Beim Lesen: Der aktuelle Wert als String. Beim Schreiben: Die jBase-Instanz.
|
|
40
|
+
*/
|
|
41
|
+
export declare function val(this: jBase, value?: string): string | jBase;
|
|
42
|
+
//# sourceMappingURL=attributes.d.ts.map
|