magtool 1.0.4 → 1.0.6

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/dist/util.js +32 -34
  2. package/package.json +1 -1
package/dist/util.js CHANGED
@@ -1,26 +1,24 @@
1
- const S = (i) => {
2
- const f = (e) => new URL((/* @__PURE__ */ Object.assign({}))[`/src/assets/img/${e}`], import.meta.url).href;
3
- i.config.globalProperties.$getImg = f, window.$getImg = f;
4
- const $ = (e, t = 0) => {
1
+ const M = (i) => {
2
+ const b = (e, t = 0) => {
5
3
  let o = parseInt(Math.random() * e);
6
4
  return o += t, o;
7
5
  };
8
- window.$rn = $;
9
- const y = (e, t) => {
6
+ window.$rn = b;
7
+ const $ = (e, t) => {
10
8
  let o = [];
11
9
  for (let r = 0; r < e; r++)
12
10
  o.push(t(r));
13
11
  return o;
14
12
  };
15
- window.$fd = y, i.config.globalProperties.$setTimeout = function(e = () => {
13
+ window.$fd = $, i.config.globalProperties.$setTimeout = function(e = () => {
16
14
  }, t) {
17
15
  this.timer && (clearTimeout(this.timer), this.timer = null), this.timer = setTimeout(() => {
18
16
  e(), clearTimeout(this.timer);
19
17
  }, t);
20
18
  };
21
- const h = (e) => e.substr(0, 1).toUpperCase() + e.substr(1, e.length).toLowerCase();
22
- window.$toUpperCamel = h;
23
- const u = (e, t = 2) => {
19
+ const y = (e) => e.substr(0, 1).toUpperCase() + e.substr(1, e.length).toLowerCase();
20
+ window.$toUpperCamel = y;
21
+ const f = (e, t = 2) => {
24
22
  const o = window.$getType(e);
25
23
  let r;
26
24
  o === "Number" ? (e = e.toFixed(t), r = String(e), e = String(Math.abs(e))) : o === "String" && (r = e, e = String(Math.abs(Number(e))));
@@ -28,14 +26,14 @@ const S = (i) => {
28
26
  let a = n[0].split("");
29
27
  a = a.reverse();
30
28
  let l = [];
31
- a.forEach((N, b) => {
32
- b !== 0 && b % 3 === 0 && l.push(","), l.push(N);
29
+ a.forEach((N, m) => {
30
+ m !== 0 && m % 3 === 0 && l.push(","), l.push(N);
33
31
  });
34
32
  let c = l.reverse().join("");
35
33
  return window.$getType(t) === "Number" && t > 0 && (c += ".", n[1] ? c += n[1].padEnd(t, 0).substr(0, t) : c += "0".padEnd(t, "0")), Number(r) !== Number(e) ? `-${c}` : c;
36
34
  };
37
- window.$fa = u, i.config.globalProperties.$fa = u;
38
- const d = ({
35
+ window.$fa = f, i.config.globalProperties.$fa = f;
36
+ const u = ({
39
37
  prop: e,
40
38
  currency: t,
41
39
  value: o,
@@ -44,18 +42,18 @@ const S = (i) => {
44
42
  const n = r[e];
45
43
  return n.unit === "currency" ? t ? `${t} ${window.$fa(o, n == null ? void 0 : n.precision)}` : window.$fa(o, n == null ? void 0 : n.precision) : n.unit === "%" ? `${window.$fa(o, n == null ? void 0 : n.precision)}%` : window.$fa(o, n == null ? void 0 : n.precision);
46
44
  };
47
- window.$fu = d, i.config.globalProperties.$fu = d;
48
- const w = (e = () => {
45
+ window.$fu = u, i.config.globalProperties.$fu = u;
46
+ const d = (e = () => {
49
47
  }, t = 2) => {
50
48
  let o = null;
51
49
  return new Promise((r, n) => {
52
- o = setTimeout(() => {
53
- e(r, n), clearTimeout(o), r(!0);
50
+ o = setTimeout(async () => {
51
+ await e(r, n), await clearTimeout(o), await r(!0);
54
52
  }, t * 100);
55
53
  });
56
54
  };
57
- window.$pm = w, window.$promise = w;
58
- const g = (e = () => {
55
+ window.$pm = d, window.$promise = d;
56
+ const w = (e = () => {
59
57
  }, t = 500) => {
60
58
  let o;
61
59
  return function(...r) {
@@ -64,7 +62,7 @@ const S = (i) => {
64
62
  }, t);
65
63
  };
66
64
  };
67
- window.$db = g, window.$debounce = g, Number.prototype.toFixedNumber = function(e) {
65
+ window.$db = w, window.$debounce = w, Number.prototype.toFixedNumber = function(e) {
68
66
  return Number(this.toFixed(e));
69
67
  }, Array.prototype.filter1 = function(e) {
70
68
  if (!e || typeof e != "function")
@@ -107,28 +105,28 @@ const S = (i) => {
107
105
  }
108
106
  };
109
107
  window.$copy = p, i.config.globalProperties.$copy = p;
110
- const F = (e) => e < 1e3 ? e : e < 1e6 ? parseInt(e / 1e3) + "K" : parseInt(e / 1e6) + "M";
111
- window.$sc = F;
112
- const C = {
108
+ const h = (e) => e < 1e3 ? e : e < 1e6 ? parseInt(e / 1e3) + "K" : parseInt(e / 1e6) + "M";
109
+ window.$sc = h;
110
+ const F = {
113
111
  cpa: "avgCPA",
114
112
  cpt: "avgCPT"
115
- }, T = (e, t = C) => {
113
+ }, C = (e, t = F) => {
116
114
  const o = t[e.name];
117
115
  o && (e.name = o);
118
116
  };
119
- window.$nr = T;
120
- const k = (e, t) => (Object.keys(e).forEach((o) => {
117
+ window.$nr = C;
118
+ const T = (e, t) => (Object.keys(e).forEach((o) => {
121
119
  objMap[o] && (e[objMap[o]] = e[o], delete e[o]);
122
120
  }), e);
123
- window.$nro = k;
124
- const P = (e) => {
121
+ window.$nro = T;
122
+ const k = (e) => {
125
123
  let t = 0;
126
124
  return Object.keys(e).forEach((o) => {
127
125
  (window.$getType(e[o]) === "Array" && e[o].length !== 0 || e[o]) && t++;
128
126
  }), t;
129
127
  };
130
- window.$pc = P;
131
- const m = {
128
+ window.$pc = k;
129
+ const g = {
132
130
  info: {
133
131
  tag: "background-color:#0085FF; color:#f1f7ff;",
134
132
  style: "background-color:#f1f7ff; color:#0085FF;"
@@ -152,8 +150,8 @@ const S = (i) => {
152
150
  }, s = (e = "info", t) => {
153
151
  e === "success" && (e = "info"), console[e](
154
152
  `%c ${e.toUpperCase()} %c┆${t}┆`,
155
- `${m[e].tag}`,
156
- `${m[e].style}`
153
+ `${g[e].tag}`,
154
+ `${g[e].style}`
157
155
  );
158
156
  };
159
157
  window.$console = {
@@ -175,5 +173,5 @@ const S = (i) => {
175
173
  };
176
174
  };
177
175
  export {
178
- S as d
176
+ M as d
179
177
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "magtool",
3
3
  "packageManager": "yarn@4.4.1",
4
- "version": "1.0.4",
4
+ "version": "1.0.6",
5
5
  "author": "magxl",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",