@daz4126/helium 0.7.2 → 0.7.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.
Files changed (2) hide show
  1. package/helium.js +14 -16
  2. package/package.json +1 -1
package/helium.js CHANGED
@@ -16,26 +16,24 @@ export default function helium(data = {}) {
16
16
  return temp.content.firstChild;
17
17
  };
18
18
 
19
- const ajax = (method, url, target, data) =>
20
- fetch(url, {
21
- method,
19
+ const ajax = (m, u, t, d) =>
20
+ fetch(u, {
21
+ method: m,
22
22
  headers: { "Content-Type": "application/json" },
23
- body: method === "GET" ? null : JSON.stringify(data),
23
+ body: m == "GET" ? null : JSON.stringify(d),
24
24
  })
25
- .then((res) =>
26
- res[
27
- res.headers.get("content-type")?.includes("json") ? "json" : "text"
28
- ](),
25
+ .then((r) =>
26
+ r[r.headers.get("content-type")?.includes("json") ? "json" : "text"](),
29
27
  )
30
- .then((result) => (state[target] = result));
28
+ .then((x) => (state[t] = x));
31
29
 
32
- const ax = (method) => (url, data, target) => ajax(method, url, target, data);
33
-
34
- const get = ax("GET");
35
- const post = ax("POST");
36
- const put = ax("PUT");
37
- const patch = ax("PATCH");
38
- const del = ax("DELETE");
30
+ const [get, post, put, patch, del] = [
31
+ "GET",
32
+ "POST",
33
+ "PUT",
34
+ "PATCH",
35
+ "DELETE",
36
+ ].map((m) => (u, d, t) => ajax(m, u, t, d));
39
37
 
40
38
  const state = new Proxy(data, {
41
39
  get(target, prop) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daz4126/helium",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "main": "helium.js",
5
5
  "type": "module",
6
6
  "keywords": [