@k37z3r/jbase 2.1.1 → 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 +8 -1
- package/README.md +1 -1
- package/dist/browser.d.ts +2 -3
- package/dist/browser.d.ts.map +1 -1
- package/dist/index.cjs +8 -3
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +97 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +8 -3
- package/dist/index.mjs.map +2 -2
- package/dist/jbase.browser.js +474 -9
- package/dist/jbase.browser.js.map +3 -3
- package/dist/jbase.min.js +2 -2
- package/dist/jbase.min.js.map +3 -3
- package/dist/server.js +10 -2
- package/dist/server.js.map +2 -2
- package/package.json +1 -1
- package/wiki/Home.md +1 -1
package/dist/jbase.browser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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.1.
|
|
3
|
+
* @version 2.1.2
|
|
4
4
|
* @homepage https://github.com/k37z3r/jBase-2
|
|
5
5
|
* @author Sven Minio (https://github.com/k37z3r/jBase-2)
|
|
6
6
|
* @license GPL-3.0-or-later
|
|
@@ -742,7 +742,7 @@
|
|
|
742
742
|
}
|
|
743
743
|
function normalizeToFragment(content, doc) {
|
|
744
744
|
const fragment = doc.createDocumentFragment();
|
|
745
|
-
const
|
|
745
|
+
const add2 = (item) => {
|
|
746
746
|
if (typeof item === "string") {
|
|
747
747
|
const temp = doc.createElement("div");
|
|
748
748
|
temp.innerHTML = item.trim();
|
|
@@ -752,10 +752,10 @@
|
|
|
752
752
|
} else if (item instanceof Node) {
|
|
753
753
|
fragment.appendChild(item);
|
|
754
754
|
} else if (item instanceof jBase || Array.isArray(item) || item instanceof NodeList) {
|
|
755
|
-
Array.from(item).forEach((child) =>
|
|
755
|
+
Array.from(item).forEach((child) => add2(child));
|
|
756
756
|
}
|
|
757
757
|
};
|
|
758
|
-
|
|
758
|
+
add2(content);
|
|
759
759
|
return fragment;
|
|
760
760
|
}
|
|
761
761
|
function remove() {
|
|
@@ -1847,6 +1847,31 @@
|
|
|
1847
1847
|
});
|
|
1848
1848
|
|
|
1849
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;
|
|
1850
1875
|
var init_arrays = __esm({
|
|
1851
1876
|
"src/modules/data/arrays.ts"() {
|
|
1852
1877
|
"use strict";
|
|
@@ -1863,10 +1888,297 @@
|
|
|
1863
1888
|
* @requires ./types
|
|
1864
1889
|
* * Depends on types.
|
|
1865
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
|
+
};
|
|
1866
2120
|
}
|
|
1867
2121
|
});
|
|
1868
2122
|
|
|
1869
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;
|
|
1870
2182
|
var init_objects = __esm({
|
|
1871
2183
|
"src/modules/data/objects.ts"() {
|
|
1872
2184
|
"use strict";
|
|
@@ -1883,10 +2195,155 @@
|
|
|
1883
2195
|
* @requires ./types
|
|
1884
2196
|
* * Depends on types.
|
|
1885
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
|
+
};
|
|
1886
2342
|
}
|
|
1887
2343
|
});
|
|
1888
2344
|
|
|
1889
2345
|
// src/modules/data/index.ts
|
|
2346
|
+
var data;
|
|
1890
2347
|
var init_data = __esm({
|
|
1891
2348
|
"src/modules/data/index.ts"() {
|
|
1892
2349
|
"use strict";
|
|
@@ -1907,11 +2364,15 @@
|
|
|
1907
2364
|
* @requires ./objects
|
|
1908
2365
|
* * Object manipulation methods.
|
|
1909
2366
|
*/
|
|
2367
|
+
data = {
|
|
2368
|
+
arr: arrays_exports,
|
|
2369
|
+
obj: objects_exports
|
|
2370
|
+
};
|
|
1910
2371
|
}
|
|
1911
2372
|
});
|
|
1912
2373
|
|
|
1913
2374
|
// src/index.ts
|
|
1914
|
-
var init, $, jB, _jB, __jB, _jBase, __jBase, jBase2, __;
|
|
2375
|
+
var initFn, init, $, jB, _jB, __jB, _jBase, __jBase, jBase2, __;
|
|
1915
2376
|
var init_index = __esm({
|
|
1916
2377
|
"src/index.ts"() {
|
|
1917
2378
|
"use strict";
|
|
@@ -1928,7 +2389,7 @@
|
|
|
1928
2389
|
init_data();
|
|
1929
2390
|
/**
|
|
1930
2391
|
* @file src/index.ts
|
|
1931
|
-
* @version 2.1.
|
|
2392
|
+
* @version 2.1.2
|
|
1932
2393
|
* @since 2.0.0
|
|
1933
2394
|
* @license GPL-3.0-or-later
|
|
1934
2395
|
* @copyright Sven Minio 2026
|
|
@@ -1959,9 +2420,14 @@
|
|
|
1959
2420
|
Object.assign(jBase.prototype, eventMethods);
|
|
1960
2421
|
Object.assign(jBase.prototype, domMethods);
|
|
1961
2422
|
Object.assign(jBase.prototype, effectMethods);
|
|
1962
|
-
|
|
2423
|
+
initFn = (selector) => {
|
|
1963
2424
|
return new jBase(selector);
|
|
1964
2425
|
};
|
|
2426
|
+
init = Object.assign(initFn, {
|
|
2427
|
+
http,
|
|
2428
|
+
data,
|
|
2429
|
+
fn: jBase.prototype
|
|
2430
|
+
});
|
|
1965
2431
|
$ = init;
|
|
1966
2432
|
jB = init;
|
|
1967
2433
|
_jB = init;
|
|
@@ -1979,7 +2445,7 @@
|
|
|
1979
2445
|
init_index();
|
|
1980
2446
|
/**
|
|
1981
2447
|
* @file src/browser.ts
|
|
1982
|
-
* @version 2.0.
|
|
2448
|
+
* @version 2.0.3
|
|
1983
2449
|
* @since 2.0.0
|
|
1984
2450
|
* @license GPL-3.0-or-later
|
|
1985
2451
|
* @copyright Sven Minio 2026
|
|
@@ -1996,7 +2462,6 @@
|
|
|
1996
2462
|
window._jBase = _jBase;
|
|
1997
2463
|
window.__jBase = __jBase;
|
|
1998
2464
|
window.__ = __;
|
|
1999
|
-
window.http = http;
|
|
2000
2465
|
console.log("jBase initialized and ready!");
|
|
2001
2466
|
}
|
|
2002
2467
|
});
|