@k37z3r/jbase 2.0.2 → 2.0.3

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/dist/index.mjs 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.0.2
3
+ * @version 2.0.3
4
4
  * @homepage https://github.com/k37z3r/jBase-2.0
5
5
  * @author Sven Minio (https://github.com/k37z3r/jBase-2.0)
6
6
  * @license GPL-3.0-or-later
@@ -1245,9 +1245,16 @@ __export(get_exports, {
1245
1245
  get: () => get,
1246
1246
  getText: () => getText
1247
1247
  });
1248
- async function get(url) {
1248
+ async function get(url, option) {
1249
+ const fetchOptions = { ...option };
1250
+ if (fetchOptions.method?.toLowerCase() === "post") {
1251
+ fetchOptions.method = "GET";
1252
+ }
1253
+ if (!fetchOptions.signal) {
1254
+ fetchOptions.signal = AbortSignal.timeout(5e3);
1255
+ }
1249
1256
  const response = await fetch(url, {
1250
- signal: AbortSignal.timeout(5e3)
1257
+ ...fetchOptions
1251
1258
  });
1252
1259
  if (!response.ok) {
1253
1260
  throw new Error(`HTTP Error: ${response.status}`);
@@ -1255,8 +1262,17 @@ async function get(url) {
1255
1262
  const text2 = await response.text();
1256
1263
  return text2 ? JSON.parse(text2) : {};
1257
1264
  }
1258
- async function getText(url) {
1259
- const response = await fetch(url);
1265
+ async function getText(url, option) {
1266
+ const fetchOptions = { ...option };
1267
+ if (fetchOptions.method?.toLowerCase() !== "get") {
1268
+ fetchOptions.method = "GET";
1269
+ }
1270
+ if (!fetchOptions.signal) {
1271
+ fetchOptions.signal = AbortSignal.timeout(5e3);
1272
+ }
1273
+ const response = await fetch(url, {
1274
+ ...fetchOptions
1275
+ });
1260
1276
  if (!response.ok) {
1261
1277
  throw new Error(`HTTP Error: ${response.status}`);
1262
1278
  }
@@ -1269,9 +1285,16 @@ var post_exports = {};
1269
1285
  __export(post_exports, {
1270
1286
  post: () => post
1271
1287
  });
1272
- async function post(url, body = {}) {
1288
+ async function post(url, body = {}, option) {
1289
+ const fetchOptions = { ...option };
1290
+ if (fetchOptions.method?.toLowerCase() !== "post") {
1291
+ fetchOptions.method = "post";
1292
+ }
1293
+ if (!fetchOptions.signal) {
1294
+ fetchOptions.signal = AbortSignal.timeout(5e3);
1295
+ }
1273
1296
  const response = await fetch(url, {
1274
- method: "POST",
1297
+ ...fetchOptions,
1275
1298
  headers: { "Content-Type": "application/json" },
1276
1299
  body: JSON.stringify(body)
1277
1300
  });
@@ -2106,7 +2129,7 @@ export {
2106
2129
  */
2107
2130
  /**
2108
2131
  * @file src/modules/http/get.ts
2109
- * @version 2.0.2
2132
+ * @version 2.0.3
2110
2133
  * @since 2.0.0
2111
2134
  * @license GPL-3.0-or-later
2112
2135
  * @copyright Sven Minio 2026
@@ -2119,8 +2142,8 @@ export {
2119
2142
  */
2120
2143
  /**
2121
2144
  * @file src/modules/http/post.ts
2122
- * @version 2.0.2
2123
- * @since 2.0.0
2145
+ * @version 2.0.3
2146
+ * @since 2.0.2
2124
2147
  * @license GPL-3.0-or-later
2125
2148
  * @copyright Sven Minio 2026
2126
2149
  * @author Sven Minio <https://sven-minio.de>