@k37z3r/jbase 2.0.3 → 2.1.2
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/CHANGELOG.md +25 -4
- package/README.md +1 -1
- package/dist/browser.d.ts +2 -3
- package/dist/browser.d.ts.map +1 -1
- package/dist/index.cjs +72 -25
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +132 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +72 -25
- package/dist/index.mjs.map +2 -2
- package/dist/jbase.browser.js +538 -31
- package/dist/jbase.browser.js.map +3 -3
- package/dist/jbase.min.js +5 -5
- package/dist/jbase.min.js.map +3 -3
- package/dist/modules/css/index.d.ts +1 -1
- package/dist/modules/css/styles.d.ts +6 -6
- package/dist/modules/css/styles.d.ts.map +1 -1
- package/dist/modules/dom/attributes.d.ts +20 -1
- package/dist/modules/dom/attributes.d.ts.map +1 -1
- package/dist/modules/dom/index.d.ts +2 -0
- package/dist/modules/dom/index.d.ts.map +1 -1
- package/dist/modules/http/get.d.ts +2 -2
- package/dist/modules/http/get.d.ts.map +1 -1
- package/dist/modules/http/index.d.ts +1 -1
- package/dist/server.js +74 -24
- package/dist/server.js.map +2 -2
- package/package.json +5 -5
- package/wiki/DOM-Attributes.md +56 -2
- package/wiki/HTTP-Requests.md +11 -14
- package/wiki/Home.md +1 -1
- package/wiki/Quick-Start.md +3 -4
package/dist/jbase.browser.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @k37z3r/jbase - A modern micro-framework for the web: jBase offers the familiar syntax of classic DOM libraries, but without their baggage. Fully typed, modular, and optimized for modern browser engines.
|
|
3
|
-
* @version 2.
|
|
4
|
-
* @homepage https://github.com/k37z3r/jBase-2
|
|
5
|
-
* @author Sven Minio (https://github.com/k37z3r/jBase-2
|
|
3
|
+
* @version 2.1.2
|
|
4
|
+
* @homepage https://github.com/k37z3r/jBase-2
|
|
5
|
+
* @author Sven Minio (https://github.com/k37z3r/jBase-2)
|
|
6
6
|
* @license GPL-3.0-or-later
|
|
7
|
-
* @copyright 2026 Sven Minio (https://github.com/k37z3r/jBase-2
|
|
7
|
+
* @copyright 2026 Sven Minio (https://github.com/k37z3r/jBase-2)
|
|
8
8
|
*/
|
|
9
9
|
"use strict";
|
|
10
10
|
(() => {
|
|
@@ -170,24 +170,46 @@
|
|
|
170
170
|
css: () => css
|
|
171
171
|
});
|
|
172
172
|
function css(property, value) {
|
|
173
|
-
if (
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
173
|
+
if (typeof property === "object" && property !== null) {
|
|
174
|
+
this.forEach((el) => {
|
|
175
|
+
if (el instanceof HTMLElement || el instanceof SVGElement) {
|
|
176
|
+
for (const key in property) {
|
|
177
|
+
if (Object.prototype.hasOwnProperty.call(property, key)) {
|
|
178
|
+
if (key.includes("-")) {
|
|
179
|
+
el.style.setProperty(key, String(property[key]));
|
|
180
|
+
} else {
|
|
181
|
+
el.style[key] = property[key];
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
182
185
|
}
|
|
183
|
-
}
|
|
184
|
-
return
|
|
186
|
+
});
|
|
187
|
+
return this;
|
|
185
188
|
}
|
|
186
|
-
|
|
187
|
-
if (
|
|
188
|
-
el
|
|
189
|
+
if (typeof property === "string") {
|
|
190
|
+
if (value === void 0) {
|
|
191
|
+
const el = this[0];
|
|
192
|
+
if (el instanceof HTMLElement || el instanceof SVGElement) {
|
|
193
|
+
const doc = el.ownerDocument;
|
|
194
|
+
const win = doc ? doc.defaultView : null;
|
|
195
|
+
if (win) {
|
|
196
|
+
return win.getComputedStyle(el).getPropertyValue(property) || win.getComputedStyle(el)[property] || "";
|
|
197
|
+
} else {
|
|
198
|
+
return el.style[property] || "";
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return "";
|
|
189
202
|
}
|
|
190
|
-
|
|
203
|
+
this.forEach((el) => {
|
|
204
|
+
if (el instanceof HTMLElement || el instanceof SVGElement) {
|
|
205
|
+
if (property.includes("-")) {
|
|
206
|
+
el.style.setProperty(property, String(value));
|
|
207
|
+
} else {
|
|
208
|
+
el.style[property] = value;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
191
213
|
return this;
|
|
192
214
|
}
|
|
193
215
|
var init_styles = __esm({
|
|
@@ -195,7 +217,7 @@
|
|
|
195
217
|
"use strict";
|
|
196
218
|
/**
|
|
197
219
|
* @file src/modules/css/styles.ts
|
|
198
|
-
* @version 2.0.
|
|
220
|
+
* @version 2.0.3
|
|
199
221
|
* @since 2.0.0
|
|
200
222
|
* @license GPL-3.0-or-later
|
|
201
223
|
* @copyright Sven Minio 2026
|
|
@@ -576,6 +598,8 @@
|
|
|
576
598
|
var attributes_exports = {};
|
|
577
599
|
__export(attributes_exports, {
|
|
578
600
|
attr: () => attr,
|
|
601
|
+
prop: () => prop,
|
|
602
|
+
removeAttr: () => removeAttr,
|
|
579
603
|
val: () => val
|
|
580
604
|
});
|
|
581
605
|
function attr(name, value) {
|
|
@@ -603,12 +627,30 @@
|
|
|
603
627
|
});
|
|
604
628
|
return this;
|
|
605
629
|
}
|
|
630
|
+
function removeAttr(name) {
|
|
631
|
+
this.forEach((el) => {
|
|
632
|
+
if (el instanceof Element) el.removeAttribute(name);
|
|
633
|
+
});
|
|
634
|
+
return this;
|
|
635
|
+
}
|
|
636
|
+
function prop(name, value) {
|
|
637
|
+
if (value === void 0) {
|
|
638
|
+
const el = this[0];
|
|
639
|
+
return el instanceof Element ? el[name] : void 0;
|
|
640
|
+
}
|
|
641
|
+
this.forEach((el) => {
|
|
642
|
+
if (el instanceof Element) {
|
|
643
|
+
el[name] = value;
|
|
644
|
+
}
|
|
645
|
+
});
|
|
646
|
+
return this;
|
|
647
|
+
}
|
|
606
648
|
var init_attributes = __esm({
|
|
607
649
|
"src/modules/dom/attributes.ts"() {
|
|
608
650
|
"use strict";
|
|
609
651
|
/**
|
|
610
652
|
* @file src/modules/dom/attributes.ts
|
|
611
|
-
* @version 2.0
|
|
653
|
+
* @version 2.1.0
|
|
612
654
|
* @since 2.0.0
|
|
613
655
|
* @license GPL-3.0-or-later
|
|
614
656
|
* @copyright Sven Minio 2026
|
|
@@ -700,7 +742,7 @@
|
|
|
700
742
|
}
|
|
701
743
|
function normalizeToFragment(content, doc) {
|
|
702
744
|
const fragment = doc.createDocumentFragment();
|
|
703
|
-
const
|
|
745
|
+
const add2 = (item) => {
|
|
704
746
|
if (typeof item === "string") {
|
|
705
747
|
const temp = doc.createElement("div");
|
|
706
748
|
temp.innerHTML = item.trim();
|
|
@@ -710,10 +752,10 @@
|
|
|
710
752
|
} else if (item instanceof Node) {
|
|
711
753
|
fragment.appendChild(item);
|
|
712
754
|
} else if (item instanceof jBase || Array.isArray(item) || item instanceof NodeList) {
|
|
713
|
-
Array.from(item).forEach((child) =>
|
|
755
|
+
Array.from(item).forEach((child) => add2(child));
|
|
714
756
|
}
|
|
715
757
|
};
|
|
716
|
-
|
|
758
|
+
add2(content);
|
|
717
759
|
return fragment;
|
|
718
760
|
}
|
|
719
761
|
function remove() {
|
|
@@ -1707,14 +1749,14 @@
|
|
|
1707
1749
|
throw new Error(`HTTP Error: ${response.status}`);
|
|
1708
1750
|
}
|
|
1709
1751
|
const text2 = await response.text();
|
|
1710
|
-
return text2
|
|
1752
|
+
return text2;
|
|
1711
1753
|
}
|
|
1712
1754
|
var init_get = __esm({
|
|
1713
1755
|
"src/modules/http/get.ts"() {
|
|
1714
1756
|
"use strict";
|
|
1715
1757
|
/**
|
|
1716
1758
|
* @file src/modules/http/get.ts
|
|
1717
|
-
* @version 2.0.
|
|
1759
|
+
* @version 2.0.4
|
|
1718
1760
|
* @since 2.0.0
|
|
1719
1761
|
* @license GPL-3.0-or-later
|
|
1720
1762
|
* @copyright Sven Minio 2026
|
|
@@ -1805,6 +1847,31 @@
|
|
|
1805
1847
|
});
|
|
1806
1848
|
|
|
1807
1849
|
// src/modules/data/arrays.ts
|
|
1850
|
+
var arrays_exports = {};
|
|
1851
|
+
__export(arrays_exports, {
|
|
1852
|
+
add: () => add,
|
|
1853
|
+
chunk: () => chunk,
|
|
1854
|
+
find: () => find,
|
|
1855
|
+
mergeArray: () => mergeArray,
|
|
1856
|
+
remove: () => remove2
|
|
1857
|
+
});
|
|
1858
|
+
function chunk(array, size) {
|
|
1859
|
+
const chunks = [];
|
|
1860
|
+
for (let i = 0; i < array.length; i += size) {
|
|
1861
|
+
chunks.push(array.slice(i, i + size));
|
|
1862
|
+
}
|
|
1863
|
+
return chunks;
|
|
1864
|
+
}
|
|
1865
|
+
function mergeArray(...arrays) {
|
|
1866
|
+
return [].concat(...arrays);
|
|
1867
|
+
}
|
|
1868
|
+
function add(array, item, index = array.length) {
|
|
1869
|
+
const copy = [...array];
|
|
1870
|
+
const idx = index < 0 ? array.length + index + 1 : index;
|
|
1871
|
+
copy.splice(idx, 0, item);
|
|
1872
|
+
return copy;
|
|
1873
|
+
}
|
|
1874
|
+
var remove2, find;
|
|
1808
1875
|
var init_arrays = __esm({
|
|
1809
1876
|
"src/modules/data/arrays.ts"() {
|
|
1810
1877
|
"use strict";
|
|
@@ -1821,10 +1888,297 @@
|
|
|
1821
1888
|
* @requires ./types
|
|
1822
1889
|
* * Depends on types.
|
|
1823
1890
|
*/
|
|
1891
|
+
remove2 = {
|
|
1892
|
+
/**
|
|
1893
|
+
* * Removes an element at a specific index.
|
|
1894
|
+
* @param array
|
|
1895
|
+
* * The array.
|
|
1896
|
+
* @param index
|
|
1897
|
+
* * The index (negative values allowed).
|
|
1898
|
+
*/
|
|
1899
|
+
at(array, index) {
|
|
1900
|
+
const copy = [...array];
|
|
1901
|
+
const idx = index < 0 ? array.length + index : index;
|
|
1902
|
+
if (idx >= 0 && idx < copy.length) {
|
|
1903
|
+
copy.splice(idx, 1);
|
|
1904
|
+
}
|
|
1905
|
+
return copy;
|
|
1906
|
+
},
|
|
1907
|
+
/**
|
|
1908
|
+
* * Removes the first element.
|
|
1909
|
+
* @param array
|
|
1910
|
+
* * The array.
|
|
1911
|
+
*/
|
|
1912
|
+
first(array) {
|
|
1913
|
+
return array.slice(1);
|
|
1914
|
+
},
|
|
1915
|
+
/**
|
|
1916
|
+
* * Removes the last element.
|
|
1917
|
+
* @param array
|
|
1918
|
+
* * The array.
|
|
1919
|
+
*/
|
|
1920
|
+
last(array) {
|
|
1921
|
+
return array.slice(0, -1);
|
|
1922
|
+
},
|
|
1923
|
+
/**
|
|
1924
|
+
* * Removes all elements matching a query condition.
|
|
1925
|
+
* @example
|
|
1926
|
+
* remove.byMatch(users, 'Admin', 'exact', 'role')
|
|
1927
|
+
* @param array
|
|
1928
|
+
* * The array.
|
|
1929
|
+
* @param query
|
|
1930
|
+
* * The search query.
|
|
1931
|
+
* @param mode
|
|
1932
|
+
* * The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
|
1933
|
+
* @param key
|
|
1934
|
+
* * (Optional) The object key if it is an array of objects.
|
|
1935
|
+
*/
|
|
1936
|
+
byMatch(array, query, mode = "exact", key) {
|
|
1937
|
+
const queryStr = String(query).toLowerCase();
|
|
1938
|
+
return array.filter((item) => {
|
|
1939
|
+
const val2 = key ? item[key] : item;
|
|
1940
|
+
const valStr = String(val2).toLowerCase();
|
|
1941
|
+
switch (mode) {
|
|
1942
|
+
case "exact":
|
|
1943
|
+
return valStr === queryStr;
|
|
1944
|
+
case "startsWith":
|
|
1945
|
+
return valStr.startsWith(queryStr);
|
|
1946
|
+
case "endsWith":
|
|
1947
|
+
return valStr.endsWith(queryStr);
|
|
1948
|
+
case "contains":
|
|
1949
|
+
return valStr.includes(queryStr);
|
|
1950
|
+
default:
|
|
1951
|
+
return false;
|
|
1952
|
+
}
|
|
1953
|
+
});
|
|
1954
|
+
}
|
|
1955
|
+
};
|
|
1956
|
+
find = {
|
|
1957
|
+
/**
|
|
1958
|
+
* * Finds the index of the first match.
|
|
1959
|
+
* @param array
|
|
1960
|
+
* * The array.
|
|
1961
|
+
* @param query
|
|
1962
|
+
* * The search query.
|
|
1963
|
+
* @param mode
|
|
1964
|
+
* * The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
|
1965
|
+
* @param key
|
|
1966
|
+
* * (Optional) The object key if it is an array of objects.
|
|
1967
|
+
* @returns
|
|
1968
|
+
* * Index or -1.
|
|
1969
|
+
*/
|
|
1970
|
+
at(array, query, mode = "exact", key) {
|
|
1971
|
+
const queryStr = String(query).toLowerCase();
|
|
1972
|
+
return array.findIndex((item) => {
|
|
1973
|
+
const val2 = key ? item[key] : item;
|
|
1974
|
+
const valStr = String(val2).toLowerCase();
|
|
1975
|
+
switch (mode) {
|
|
1976
|
+
case "exact":
|
|
1977
|
+
return valStr === queryStr;
|
|
1978
|
+
case "startsWith":
|
|
1979
|
+
return valStr.startsWith(queryStr);
|
|
1980
|
+
case "endsWith":
|
|
1981
|
+
return valStr.endsWith(queryStr);
|
|
1982
|
+
case "contains":
|
|
1983
|
+
return valStr.includes(queryStr);
|
|
1984
|
+
default:
|
|
1985
|
+
return false;
|
|
1986
|
+
}
|
|
1987
|
+
});
|
|
1988
|
+
},
|
|
1989
|
+
/**
|
|
1990
|
+
* * Returns all elements matching the condition (Filter).
|
|
1991
|
+
* @param array
|
|
1992
|
+
* * The array.
|
|
1993
|
+
* @param query
|
|
1994
|
+
* * The search query.
|
|
1995
|
+
* @param mode
|
|
1996
|
+
* * The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
|
1997
|
+
* @param key
|
|
1998
|
+
* * (Optional) The object key if it is an array of objects.
|
|
1999
|
+
* @returns
|
|
2000
|
+
* * All matching elements or -1.
|
|
2001
|
+
*/
|
|
2002
|
+
all(array, query, mode = "exact", key) {
|
|
2003
|
+
const queryStr = String(query).toLowerCase();
|
|
2004
|
+
return array.filter((item) => {
|
|
2005
|
+
const val2 = key ? item[key] : item;
|
|
2006
|
+
const valStr = String(val2).toLowerCase();
|
|
2007
|
+
switch (mode) {
|
|
2008
|
+
case "exact":
|
|
2009
|
+
return valStr === queryStr;
|
|
2010
|
+
case "startsWith":
|
|
2011
|
+
return valStr.startsWith(queryStr);
|
|
2012
|
+
case "endsWith":
|
|
2013
|
+
return valStr.endsWith(queryStr);
|
|
2014
|
+
case "contains":
|
|
2015
|
+
return valStr.includes(queryStr);
|
|
2016
|
+
default:
|
|
2017
|
+
return false;
|
|
2018
|
+
}
|
|
2019
|
+
});
|
|
2020
|
+
},
|
|
2021
|
+
/**
|
|
2022
|
+
* * Returns the first matching element (or undefined).
|
|
2023
|
+
* @param array
|
|
2024
|
+
* * The array.
|
|
2025
|
+
* @param query
|
|
2026
|
+
* * The search query.
|
|
2027
|
+
* @param mode
|
|
2028
|
+
* * The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
|
2029
|
+
* @param key
|
|
2030
|
+
* * (Optional) The object key if it is an array of objects.
|
|
2031
|
+
* @returns
|
|
2032
|
+
* * Index or -1.
|
|
2033
|
+
*/
|
|
2034
|
+
first(array, query, mode = "exact", key) {
|
|
2035
|
+
const queryStr = String(query).toLowerCase();
|
|
2036
|
+
return array.find((item) => {
|
|
2037
|
+
const val2 = key ? item[key] : item;
|
|
2038
|
+
const valStr = String(val2).toLowerCase();
|
|
2039
|
+
switch (mode) {
|
|
2040
|
+
case "exact":
|
|
2041
|
+
return valStr === queryStr;
|
|
2042
|
+
case "startsWith":
|
|
2043
|
+
return valStr.startsWith(queryStr);
|
|
2044
|
+
case "endsWith":
|
|
2045
|
+
return valStr.endsWith(queryStr);
|
|
2046
|
+
case "contains":
|
|
2047
|
+
return valStr.includes(queryStr);
|
|
2048
|
+
default:
|
|
2049
|
+
return false;
|
|
2050
|
+
}
|
|
2051
|
+
});
|
|
2052
|
+
},
|
|
2053
|
+
/**
|
|
2054
|
+
* * Returns the last matching element (or undefined).
|
|
2055
|
+
* @param array
|
|
2056
|
+
* * The array.
|
|
2057
|
+
* @param query
|
|
2058
|
+
* * The search query.
|
|
2059
|
+
* @param mode
|
|
2060
|
+
* * The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
|
2061
|
+
* @param key
|
|
2062
|
+
* * (Optional) The object key if it is an array of objects.
|
|
2063
|
+
* @returns
|
|
2064
|
+
* * Index or -1.
|
|
2065
|
+
*/
|
|
2066
|
+
last(array, query, mode = "exact", key) {
|
|
2067
|
+
const queryStr = String(query).toLowerCase();
|
|
2068
|
+
return [...array].reverse().find((item) => {
|
|
2069
|
+
const val2 = key ? item[key] : item;
|
|
2070
|
+
const valStr = String(val2).toLowerCase();
|
|
2071
|
+
switch (mode) {
|
|
2072
|
+
case "exact":
|
|
2073
|
+
return valStr === queryStr;
|
|
2074
|
+
case "startsWith":
|
|
2075
|
+
return valStr.startsWith(queryStr);
|
|
2076
|
+
case "endsWith":
|
|
2077
|
+
return valStr.endsWith(queryStr);
|
|
2078
|
+
case "contains":
|
|
2079
|
+
return valStr.includes(queryStr);
|
|
2080
|
+
default:
|
|
2081
|
+
return false;
|
|
2082
|
+
}
|
|
2083
|
+
});
|
|
2084
|
+
},
|
|
2085
|
+
/**
|
|
2086
|
+
* * Removes all elements matching a query condition.
|
|
2087
|
+
* @example
|
|
2088
|
+
* find.byMatch(users, 'Admin', 'exact', 'role')
|
|
2089
|
+
* @param array
|
|
2090
|
+
* * The array.
|
|
2091
|
+
* @param query
|
|
2092
|
+
* * The search query.
|
|
2093
|
+
* @param mode
|
|
2094
|
+
* * The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
|
2095
|
+
* @param key
|
|
2096
|
+
* * (Optional) The object key if it is an array of objects.
|
|
2097
|
+
* @returns
|
|
2098
|
+
* * Index or -1.
|
|
2099
|
+
*/
|
|
2100
|
+
byMatch(array, query, mode = "exact", key) {
|
|
2101
|
+
const queryStr = String(query).toLowerCase();
|
|
2102
|
+
return array.findIndex((item) => {
|
|
2103
|
+
const val2 = key ? item[key] : item;
|
|
2104
|
+
const valStr = String(val2).toLowerCase();
|
|
2105
|
+
switch (mode) {
|
|
2106
|
+
case "exact":
|
|
2107
|
+
return valStr === queryStr;
|
|
2108
|
+
case "startsWith":
|
|
2109
|
+
return valStr.startsWith(queryStr);
|
|
2110
|
+
case "endsWith":
|
|
2111
|
+
return valStr.endsWith(queryStr);
|
|
2112
|
+
case "contains":
|
|
2113
|
+
return valStr.includes(queryStr);
|
|
2114
|
+
default:
|
|
2115
|
+
return false;
|
|
2116
|
+
}
|
|
2117
|
+
});
|
|
2118
|
+
}
|
|
2119
|
+
};
|
|
1824
2120
|
}
|
|
1825
2121
|
});
|
|
1826
2122
|
|
|
1827
2123
|
// src/modules/data/objects.ts
|
|
2124
|
+
var objects_exports = {};
|
|
2125
|
+
__export(objects_exports, {
|
|
2126
|
+
find: () => find2,
|
|
2127
|
+
get: () => get2,
|
|
2128
|
+
mergeObjects: () => mergeObjects,
|
|
2129
|
+
omit: () => omit,
|
|
2130
|
+
pick: () => pick,
|
|
2131
|
+
set: () => set
|
|
2132
|
+
});
|
|
2133
|
+
function mergeObjects(target, ...sources) {
|
|
2134
|
+
if (!sources.length)
|
|
2135
|
+
return target;
|
|
2136
|
+
const source = sources.shift();
|
|
2137
|
+
if (isObject(target) && isObject(source)) {
|
|
2138
|
+
for (const key in source) {
|
|
2139
|
+
if (key === "__proto__" || key === "constructor")
|
|
2140
|
+
continue;
|
|
2141
|
+
if (isObject(source[key])) {
|
|
2142
|
+
if (!target[key]) target[key] = {};
|
|
2143
|
+
mergeObjects(target[key], source[key]);
|
|
2144
|
+
} else {
|
|
2145
|
+
target[key] = source[key];
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
return mergeObjects(target, ...sources);
|
|
2150
|
+
}
|
|
2151
|
+
function pick(obj, keys) {
|
|
2152
|
+
const ret = {};
|
|
2153
|
+
keys.forEach((key) => {
|
|
2154
|
+
if (key in obj) ret[key] = obj[key];
|
|
2155
|
+
});
|
|
2156
|
+
return ret;
|
|
2157
|
+
}
|
|
2158
|
+
function omit(obj, keys) {
|
|
2159
|
+
const ret = { ...obj };
|
|
2160
|
+
keys.forEach((key) => {
|
|
2161
|
+
delete ret[key];
|
|
2162
|
+
});
|
|
2163
|
+
return ret;
|
|
2164
|
+
}
|
|
2165
|
+
function get2(obj, path) {
|
|
2166
|
+
return path.split(".").reduce((acc, part) => acc && acc[part], obj);
|
|
2167
|
+
}
|
|
2168
|
+
function set(obj, path, value) {
|
|
2169
|
+
const parts = path.split(".");
|
|
2170
|
+
let current = obj;
|
|
2171
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
2172
|
+
const part = parts[i];
|
|
2173
|
+
if (!current[part]) current[part] = {};
|
|
2174
|
+
current = current[part];
|
|
2175
|
+
}
|
|
2176
|
+
current[parts[parts.length - 1]] = value;
|
|
2177
|
+
}
|
|
2178
|
+
function isObject(item) {
|
|
2179
|
+
return item && typeof item === "object" && !Array.isArray(item);
|
|
2180
|
+
}
|
|
2181
|
+
var find2;
|
|
1828
2182
|
var init_objects = __esm({
|
|
1829
2183
|
"src/modules/data/objects.ts"() {
|
|
1830
2184
|
"use strict";
|
|
@@ -1841,10 +2195,155 @@
|
|
|
1841
2195
|
* @requires ./types
|
|
1842
2196
|
* * Depends on types.
|
|
1843
2197
|
*/
|
|
2198
|
+
find2 = {
|
|
2199
|
+
/**
|
|
2200
|
+
* * Returns the n-th entry of an object as a [key, value] pair. Supports negative indices.
|
|
2201
|
+
* @example find.at({ a: 1, b: 2 }, 1) => ['b', 2]
|
|
2202
|
+
* @param obj
|
|
2203
|
+
* * The object to search.
|
|
2204
|
+
* @param index
|
|
2205
|
+
* * The index (0-based, negative counts from the back).
|
|
2206
|
+
* @returns
|
|
2207
|
+
* * A [key, value] tuple or undefined.
|
|
2208
|
+
*/
|
|
2209
|
+
at(obj, index) {
|
|
2210
|
+
const entries = Object.entries(obj);
|
|
2211
|
+
const idx = index < 0 ? entries.length + index : index;
|
|
2212
|
+
return entries[idx];
|
|
2213
|
+
},
|
|
2214
|
+
/**
|
|
2215
|
+
* * Finds the first entry where the key or value matches the query.
|
|
2216
|
+
* @example find.first(config, 'admin', 'exact', 'key')
|
|
2217
|
+
* @param obj
|
|
2218
|
+
* * The object to search.
|
|
2219
|
+
* @param query
|
|
2220
|
+
* * The search query.
|
|
2221
|
+
* @param mode
|
|
2222
|
+
* * The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
|
2223
|
+
* @param searchBy
|
|
2224
|
+
* * Whether to search by 'key' or 'value'.
|
|
2225
|
+
* @returns
|
|
2226
|
+
* * The first matching [key, value] pair or undefined.
|
|
2227
|
+
*/
|
|
2228
|
+
first(obj, query, mode = "exact", searchBy = "key") {
|
|
2229
|
+
const entries = Object.entries(obj);
|
|
2230
|
+
const queryStr = String(query).toLowerCase();
|
|
2231
|
+
return entries.find(([key, val2]) => {
|
|
2232
|
+
const target = searchBy === "key" ? key : val2;
|
|
2233
|
+
const valStr = String(target).toLowerCase();
|
|
2234
|
+
switch (mode) {
|
|
2235
|
+
case "exact":
|
|
2236
|
+
return valStr === queryStr;
|
|
2237
|
+
case "startsWith":
|
|
2238
|
+
return valStr.startsWith(queryStr);
|
|
2239
|
+
case "endsWith":
|
|
2240
|
+
return valStr.endsWith(queryStr);
|
|
2241
|
+
case "contains":
|
|
2242
|
+
return valStr.includes(queryStr);
|
|
2243
|
+
default:
|
|
2244
|
+
return false;
|
|
2245
|
+
}
|
|
2246
|
+
});
|
|
2247
|
+
},
|
|
2248
|
+
/**
|
|
2249
|
+
* * Finds the last entry where the key or value matches the query.
|
|
2250
|
+
* @example find.last(config, '.php', 'endsWith', 'key')
|
|
2251
|
+
* @param obj
|
|
2252
|
+
* * The object to search.
|
|
2253
|
+
* @param query
|
|
2254
|
+
* * The search query.
|
|
2255
|
+
* @param mode
|
|
2256
|
+
* * The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
|
2257
|
+
* @param searchBy
|
|
2258
|
+
* * Whether to search by 'key' or 'value'.
|
|
2259
|
+
* @returns
|
|
2260
|
+
* * The last matching [key, value] pair or undefined.
|
|
2261
|
+
*/
|
|
2262
|
+
last(obj, query, mode = "exact", searchBy = "key") {
|
|
2263
|
+
const entries = Object.entries(obj);
|
|
2264
|
+
const queryStr = String(query).toLowerCase();
|
|
2265
|
+
return [...entries].reverse().find(([key, val2]) => {
|
|
2266
|
+
const target = searchBy === "key" ? key : val2;
|
|
2267
|
+
const valStr = String(target).toLowerCase();
|
|
2268
|
+
switch (mode) {
|
|
2269
|
+
case "exact":
|
|
2270
|
+
return valStr === queryStr;
|
|
2271
|
+
case "startsWith":
|
|
2272
|
+
return valStr.startsWith(queryStr);
|
|
2273
|
+
case "endsWith":
|
|
2274
|
+
return valStr.endsWith(queryStr);
|
|
2275
|
+
case "contains":
|
|
2276
|
+
return valStr.includes(queryStr);
|
|
2277
|
+
default:
|
|
2278
|
+
return false;
|
|
2279
|
+
}
|
|
2280
|
+
});
|
|
2281
|
+
},
|
|
2282
|
+
/**
|
|
2283
|
+
* * Finds all keys matching the query.
|
|
2284
|
+
* @example find.key(config, 'api_', 'startsWith')
|
|
2285
|
+
* @param obj
|
|
2286
|
+
* * The object to search.
|
|
2287
|
+
* @param query
|
|
2288
|
+
* * The search query.
|
|
2289
|
+
* @param mode
|
|
2290
|
+
* * The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
|
2291
|
+
* @returns
|
|
2292
|
+
* * An array of matching keys.
|
|
2293
|
+
*/
|
|
2294
|
+
key(obj, query, mode = "exact") {
|
|
2295
|
+
const queryStr = String(query).toLowerCase();
|
|
2296
|
+
return Object.keys(obj).filter((key) => {
|
|
2297
|
+
const valStr = String(key).toLowerCase();
|
|
2298
|
+
switch (mode) {
|
|
2299
|
+
case "exact":
|
|
2300
|
+
return valStr === queryStr;
|
|
2301
|
+
case "startsWith":
|
|
2302
|
+
return valStr.startsWith(queryStr);
|
|
2303
|
+
case "endsWith":
|
|
2304
|
+
return valStr.endsWith(queryStr);
|
|
2305
|
+
case "contains":
|
|
2306
|
+
return valStr.includes(queryStr);
|
|
2307
|
+
default:
|
|
2308
|
+
return false;
|
|
2309
|
+
}
|
|
2310
|
+
});
|
|
2311
|
+
},
|
|
2312
|
+
/**
|
|
2313
|
+
* * Finds all values matching the query.
|
|
2314
|
+
* @param obj
|
|
2315
|
+
* * The object to search.
|
|
2316
|
+
* @param query
|
|
2317
|
+
* * The search query.
|
|
2318
|
+
* @param mode
|
|
2319
|
+
* * The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
|
2320
|
+
* @returns
|
|
2321
|
+
* * An array of matching values.
|
|
2322
|
+
*/
|
|
2323
|
+
value(obj, query, mode = "exact") {
|
|
2324
|
+
const queryStr = String(query).toLowerCase();
|
|
2325
|
+
return Object.values(obj).filter((val2) => {
|
|
2326
|
+
const valStr = String(val2).toLowerCase();
|
|
2327
|
+
switch (mode) {
|
|
2328
|
+
case "exact":
|
|
2329
|
+
return valStr === queryStr;
|
|
2330
|
+
case "startsWith":
|
|
2331
|
+
return valStr.startsWith(queryStr);
|
|
2332
|
+
case "endsWith":
|
|
2333
|
+
return valStr.endsWith(queryStr);
|
|
2334
|
+
case "contains":
|
|
2335
|
+
return valStr.includes(queryStr);
|
|
2336
|
+
default:
|
|
2337
|
+
return false;
|
|
2338
|
+
}
|
|
2339
|
+
});
|
|
2340
|
+
}
|
|
2341
|
+
};
|
|
1844
2342
|
}
|
|
1845
2343
|
});
|
|
1846
2344
|
|
|
1847
2345
|
// src/modules/data/index.ts
|
|
2346
|
+
var data;
|
|
1848
2347
|
var init_data = __esm({
|
|
1849
2348
|
"src/modules/data/index.ts"() {
|
|
1850
2349
|
"use strict";
|
|
@@ -1865,11 +2364,15 @@
|
|
|
1865
2364
|
* @requires ./objects
|
|
1866
2365
|
* * Object manipulation methods.
|
|
1867
2366
|
*/
|
|
2367
|
+
data = {
|
|
2368
|
+
arr: arrays_exports,
|
|
2369
|
+
obj: objects_exports
|
|
2370
|
+
};
|
|
1868
2371
|
}
|
|
1869
2372
|
});
|
|
1870
2373
|
|
|
1871
2374
|
// src/index.ts
|
|
1872
|
-
var init, $, jB, _jB, __jB, _jBase, __jBase, jBase2, __;
|
|
2375
|
+
var initFn, init, $, jB, _jB, __jB, _jBase, __jBase, jBase2, __;
|
|
1873
2376
|
var init_index = __esm({
|
|
1874
2377
|
"src/index.ts"() {
|
|
1875
2378
|
"use strict";
|
|
@@ -1886,7 +2389,7 @@
|
|
|
1886
2389
|
init_data();
|
|
1887
2390
|
/**
|
|
1888
2391
|
* @file src/index.ts
|
|
1889
|
-
* @version 2.
|
|
2392
|
+
* @version 2.1.2
|
|
1890
2393
|
* @since 2.0.0
|
|
1891
2394
|
* @license GPL-3.0-or-later
|
|
1892
2395
|
* @copyright Sven Minio 2026
|
|
@@ -1917,9 +2420,14 @@
|
|
|
1917
2420
|
Object.assign(jBase.prototype, eventMethods);
|
|
1918
2421
|
Object.assign(jBase.prototype, domMethods);
|
|
1919
2422
|
Object.assign(jBase.prototype, effectMethods);
|
|
1920
|
-
|
|
2423
|
+
initFn = (selector) => {
|
|
1921
2424
|
return new jBase(selector);
|
|
1922
2425
|
};
|
|
2426
|
+
init = Object.assign(initFn, {
|
|
2427
|
+
http,
|
|
2428
|
+
data,
|
|
2429
|
+
fn: jBase.prototype
|
|
2430
|
+
});
|
|
1923
2431
|
$ = init;
|
|
1924
2432
|
jB = init;
|
|
1925
2433
|
_jB = init;
|
|
@@ -1937,7 +2445,7 @@
|
|
|
1937
2445
|
init_index();
|
|
1938
2446
|
/**
|
|
1939
2447
|
* @file src/browser.ts
|
|
1940
|
-
* @version 2.0.
|
|
2448
|
+
* @version 2.0.3
|
|
1941
2449
|
* @since 2.0.0
|
|
1942
2450
|
* @license GPL-3.0-or-later
|
|
1943
2451
|
* @copyright Sven Minio 2026
|
|
@@ -1954,7 +2462,6 @@
|
|
|
1954
2462
|
window._jBase = _jBase;
|
|
1955
2463
|
window.__jBase = __jBase;
|
|
1956
2464
|
window.__ = __;
|
|
1957
|
-
window.http = http;
|
|
1958
2465
|
console.log("jBase initialized and ready!");
|
|
1959
2466
|
}
|
|
1960
2467
|
});
|