@aliexme/js-utils 2.4.1 → 3.0.0

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 (53) hide show
  1. package/dist/array/arraysIntersection.js +8 -10
  2. package/dist/array/groupArrayItems.js +9 -9
  3. package/dist/array/randomArrayItem.js +4 -7
  4. package/dist/array/subtractArrays.js +8 -8
  5. package/dist/array/uniquify.js +4 -4
  6. package/dist/async/asyncResult.js +5 -5
  7. package/dist/async/asyncify.js +5 -5
  8. package/dist/async/sleep.js +4 -4
  9. package/dist/function/debounce.js +23 -25
  10. package/dist/function/noop.js +4 -5
  11. package/dist/function/throttle.js +20 -22
  12. package/dist/index.js +24 -50
  13. package/dist/number/clamp.js +4 -4
  14. package/dist/number/floor.js +4 -4
  15. package/dist/number/lerp.js +4 -4
  16. package/dist/number/randomInt.js +5 -5
  17. package/dist/number/randomNumber.js +6 -6
  18. package/dist/number/round.js +4 -4
  19. package/dist/object/findObjectKey.js +4 -4
  20. package/dist/object/getObjectKey.js +5 -5
  21. package/dist/object/objectForEach.js +11 -8
  22. package/dist/object/omitObjectProperties.js +9 -9
  23. package/dist/object/omitUndefinedObjectValues.js +9 -9
  24. package/dist/string/capitalize.js +4 -4
  25. package/dist/string/randomString.js +43 -18
  26. package/dist/string/secureString.js +8 -9
  27. package/package.json +4 -7
  28. package/dist/array/arraysIntersection.cjs +0 -1
  29. package/dist/array/groupArrayItems.cjs +0 -1
  30. package/dist/array/randomArrayItem.cjs +0 -1
  31. package/dist/array/subtractArrays.cjs +0 -1
  32. package/dist/array/uniquify.cjs +0 -1
  33. package/dist/async/asyncResult.cjs +0 -1
  34. package/dist/async/asyncify.cjs +0 -1
  35. package/dist/async/sleep.cjs +0 -1
  36. package/dist/function/debounce.cjs +0 -1
  37. package/dist/function/noop.cjs +0 -1
  38. package/dist/function/throttle.cjs +0 -1
  39. package/dist/index.cjs +0 -1
  40. package/dist/number/clamp.cjs +0 -1
  41. package/dist/number/floor.cjs +0 -1
  42. package/dist/number/lerp.cjs +0 -1
  43. package/dist/number/randomInt.cjs +0 -1
  44. package/dist/number/randomNumber.cjs +0 -1
  45. package/dist/number/round.cjs +0 -1
  46. package/dist/object/findObjectKey.cjs +0 -1
  47. package/dist/object/getObjectKey.cjs +0 -1
  48. package/dist/object/objectForEach.cjs +0 -1
  49. package/dist/object/omitObjectProperties.cjs +0 -1
  50. package/dist/object/omitUndefinedObjectValues.cjs +0 -1
  51. package/dist/string/capitalize.cjs +0 -1
  52. package/dist/string/randomString.cjs +0 -1
  53. package/dist/string/secureString.cjs +0 -1
@@ -1,11 +1,9 @@
1
- function i(n, o, ...r) {
2
- if (n.length === 0 || o.length === 0 || r.some((t) => t.length === 0)) return [];
3
- const e = new Set(n), f = [o, ...r];
4
- for (const t of f)
5
- for (const c of e)
6
- t.includes(c) || e.delete(c);
7
- return Array.from(e);
1
+ //#region src/array/arraysIntersection.ts
2
+ function e(e, t, ...n) {
3
+ if (e.length === 0 || t.length === 0 || n.some((e) => e.length === 0)) return [];
4
+ let r = new Set(e), i = [t, ...n];
5
+ for (let e of i) for (let t of r) e.includes(t) || r.delete(t);
6
+ return Array.from(r);
8
7
  }
9
- export {
10
- i as arraysIntersection
11
- };
8
+ //#endregion
9
+ export { e as arraysIntersection };
@@ -1,10 +1,10 @@
1
- const n = (t, c) => {
2
- const o = {};
3
- return t.forEach((r) => {
4
- const s = r[c], e = o[s];
5
- e ? e.push(r) : o[s] = [r];
6
- }), o;
7
- };
8
- export {
9
- n as groupArrayItems
1
+ //#region src/array/groupArrayItems.ts
2
+ var e = (e, t) => {
3
+ let n = {};
4
+ return e.forEach((e) => {
5
+ let r = e[t], i = n[r];
6
+ i ? i.push(e) : n[r] = [e];
7
+ }), n;
10
8
  };
9
+ //#endregion
10
+ export { e as groupArrayItems };
@@ -1,7 +1,4 @@
1
- const t = (n) => {
2
- const o = Math.floor(Math.random() * n.length);
3
- return n[o];
4
- };
5
- export {
6
- t as randomArrayItem
7
- };
1
+ //#region src/array/randomArrayItem.ts
2
+ var e = (e) => e[Math.floor(Math.random() * e.length)];
3
+ //#endregion
4
+ export { e as randomArrayItem };
@@ -1,9 +1,9 @@
1
- function c(t, e, ...n) {
2
- if (t.length === 0) return [];
3
- if (e.length === 0) return [...t];
4
- const r = [e, ...n], s = new Set(r.flat());
5
- return t.filter((u) => !s.has(u));
1
+ //#region src/array/subtractArrays.ts
2
+ function e(e, t, ...n) {
3
+ if (e.length === 0) return [];
4
+ if (t.length === 0) return [...e];
5
+ let r = [t, ...n], i = new Set(r.flat());
6
+ return e.filter((e) => !i.has(e));
6
7
  }
7
- export {
8
- c as subtractArrays
9
- };
8
+ //#endregion
9
+ export { e as subtractArrays };
@@ -1,4 +1,4 @@
1
- const n = (e) => [...new Set(e)];
2
- export {
3
- n as uniquify
4
- };
1
+ //#region src/array/uniquify.ts
2
+ var e = (e) => [...new Set(e)];
3
+ //#endregion
4
+ export { e as uniquify };
@@ -1,5 +1,5 @@
1
- import { asyncify as s } from "./asyncify.js";
2
- const o = (n) => s(n)();
3
- export {
4
- o as asyncResult
5
- };
1
+ import { asyncify as e } from "./asyncify.js";
2
+ //#region src/async/asyncResult.ts
3
+ var t = (t) => e(t)();
4
+ //#endregion
5
+ export { t as asyncResult };
@@ -1,6 +1,6 @@
1
- const n = (e) => (...r) => new Promise((t) => {
2
- setTimeout(() => t(e(...r)), 0);
1
+ //#region src/async/asyncify.ts
2
+ var e = (e) => (...t) => new Promise((n) => {
3
+ setTimeout(() => n(e(...t)), 0);
3
4
  });
4
- export {
5
- n as asyncify
6
- };
5
+ //#endregion
6
+ export { e as asyncify };
@@ -1,4 +1,4 @@
1
- const t = async (e) => new Promise((s) => setTimeout(s, e));
2
- export {
3
- t as sleep
4
- };
1
+ //#region src/async/sleep.ts
2
+ var e = async (e) => new Promise((t) => setTimeout(t, e));
3
+ //#endregion
4
+ export { e as sleep };
@@ -1,26 +1,24 @@
1
- import { clamp as C } from "../number/clamp.js";
2
- const p = (l, i, m = {}) => {
3
- const { maxWait: c, withLeading: f = !1 } = m;
4
- let t = null, e = null;
5
- const o = () => {
6
- t !== null && (clearTimeout(t), t = null);
7
- }, n = () => {
8
- e = null;
9
- }, T = () => {
10
- o(), n();
11
- }, s = (...r) => {
12
- o();
13
- const a = Date.now(), d = e ? a - e : 0, u = c ? C(c - d, 0, i) : i;
14
- if (!e && (e = a, f)) {
15
- l(...r), t = setTimeout(n, u);
16
- return;
17
- }
18
- t = setTimeout(() => {
19
- l(...r), n();
20
- }, u);
21
- };
22
- return s.cancel = T, s;
23
- };
24
- export {
25
- p as debounce
1
+ import { clamp as e } from "../number/clamp.js";
2
+ //#region src/function/debounce.ts
3
+ var t = (t, n, r = {}) => {
4
+ let { maxWait: i, withLeading: a = !1 } = r, o = null, s = null, c = () => {
5
+ o !== null && (clearTimeout(o), o = null);
6
+ }, l = () => {
7
+ s = null;
8
+ }, u = () => {
9
+ c(), l();
10
+ }, d = (...r) => {
11
+ c();
12
+ let u = Date.now(), d = s ? u - s : 0, f = i ? e(i - d, 0, n) : n;
13
+ if (!s && (s = u, a)) {
14
+ t(...r), o = setTimeout(l, f);
15
+ return;
16
+ }
17
+ o = setTimeout(() => {
18
+ t(...r), l();
19
+ }, f);
20
+ };
21
+ return d.cancel = u, d;
26
22
  };
23
+ //#endregion
24
+ export { t as debounce };
@@ -1,5 +1,4 @@
1
- const o = () => {
2
- };
3
- export {
4
- o as noop
5
- };
1
+ //#region src/function/noop.ts
2
+ var e = () => {};
3
+ //#endregion
4
+ export { e as noop };
@@ -1,23 +1,21 @@
1
- const f = (n, c, s = {}) => {
2
- const { withTrailing: T = !1 } = s;
3
- let e = null, l = null, t = !1;
4
- const o = () => {
5
- e !== null && (clearTimeout(e), e = null);
6
- }, m = () => {
7
- l !== null && (clearTimeout(l), l = null);
8
- }, r = () => {
9
- t = !1;
10
- }, a = () => {
11
- o(), m(), r();
12
- }, i = (...u) => {
13
- if (t) {
14
- T && (o(), e = setTimeout(() => n(...u), c));
15
- return;
16
- }
17
- o(), n(...u), t = !0, l = setTimeout(r, c);
18
- };
19
- return i.cancel = a, i;
20
- };
21
- export {
22
- f as throttle
1
+ //#region src/function/throttle.ts
2
+ var e = (e, t, n = {}) => {
3
+ let { withTrailing: r = !1 } = n, i = null, a = null, o = !1, s = () => {
4
+ i !== null && (clearTimeout(i), i = null);
5
+ }, c = () => {
6
+ a !== null && (clearTimeout(a), a = null);
7
+ }, l = () => {
8
+ o = !1;
9
+ }, u = () => {
10
+ s(), c(), l();
11
+ }, d = (...n) => {
12
+ if (o) {
13
+ r && (s(), i = setTimeout(() => e(...n), t));
14
+ return;
15
+ }
16
+ s(), e(...n), o = !0, a = setTimeout(l, t);
17
+ };
18
+ return d.cancel = u, d;
23
19
  };
20
+ //#endregion
21
+ export { e as throttle };
package/dist/index.js CHANGED
@@ -1,52 +1,26 @@
1
1
  import { arraysIntersection as e } from "./array/arraysIntersection.js";
2
- import { asyncResult as m } from "./async/asyncResult.js";
3
- import { asyncify as f } from "./async/asyncify.js";
4
- import { capitalize as n } from "./string/capitalize.js";
2
+ import { groupArrayItems as t } from "./array/groupArrayItems.js";
3
+ import { randomArrayItem as n } from "./array/randomArrayItem.js";
4
+ import { subtractArrays as r } from "./array/subtractArrays.js";
5
+ import { uniquify as i } from "./array/uniquify.js";
6
+ import { asyncify as a } from "./async/asyncify.js";
7
+ import { asyncResult as o } from "./async/asyncResult.js";
8
+ import { sleep as s } from "./async/sleep.js";
5
9
  import { clamp as c } from "./number/clamp.js";
6
- import { debounce as s } from "./function/debounce.js";
7
- import { findObjectKey as y } from "./object/findObjectKey.js";
8
- import { floor as b } from "./number/floor.js";
9
- import { getObjectKey as j } from "./object/getObjectKey.js";
10
- import { groupArrayItems as I } from "./array/groupArrayItems.js";
11
- import { lerp as A } from "./number/lerp.js";
12
- import { noop as K } from "./function/noop.js";
13
- import { objectForEach as q } from "./object/objectForEach.js";
14
- import { omitObjectProperties as E } from "./object/omitObjectProperties.js";
15
- import { omitUndefinedObjectValues as N } from "./object/omitUndefinedObjectValues.js";
16
- import { randomArrayItem as R } from "./array/randomArrayItem.js";
17
- import { randomInt as V } from "./number/randomInt.js";
18
- import { randomNumber as v } from "./number/randomNumber.js";
19
- import { randomString as B } from "./string/randomString.js";
20
- import { round as D } from "./number/round.js";
21
- import { secureString as H } from "./string/secureString.js";
22
- import { sleep as L } from "./async/sleep.js";
23
- import { subtractArrays as Q } from "./array/subtractArrays.js";
24
- import { throttle as W } from "./function/throttle.js";
25
- import { uniquify as Y } from "./array/uniquify.js";
26
- export {
27
- e as arraysIntersection,
28
- m as asyncResult,
29
- f as asyncify,
30
- n as capitalize,
31
- c as clamp,
32
- s as debounce,
33
- y as findObjectKey,
34
- b as floor,
35
- j as getObjectKey,
36
- I as groupArrayItems,
37
- A as lerp,
38
- K as noop,
39
- q as objectForEach,
40
- E as omitObjectProperties,
41
- N as omitUndefinedObjectValues,
42
- R as randomArrayItem,
43
- V as randomInt,
44
- v as randomNumber,
45
- B as randomString,
46
- D as round,
47
- H as secureString,
48
- L as sleep,
49
- Q as subtractArrays,
50
- W as throttle,
51
- Y as uniquify
52
- };
10
+ import { debounce as l } from "./function/debounce.js";
11
+ import { noop as u } from "./function/noop.js";
12
+ import { throttle as d } from "./function/throttle.js";
13
+ import { floor as f } from "./number/floor.js";
14
+ import { lerp as p } from "./number/lerp.js";
15
+ import { randomNumber as m } from "./number/randomNumber.js";
16
+ import { randomInt as h } from "./number/randomInt.js";
17
+ import { round as g } from "./number/round.js";
18
+ import { findObjectKey as _ } from "./object/findObjectKey.js";
19
+ import { getObjectKey as v } from "./object/getObjectKey.js";
20
+ import { objectForEach as y } from "./object/objectForEach.js";
21
+ import { omitObjectProperties as b } from "./object/omitObjectProperties.js";
22
+ import { omitUndefinedObjectValues as x } from "./object/omitUndefinedObjectValues.js";
23
+ import { capitalize as S } from "./string/capitalize.js";
24
+ import { randomString as C } from "./string/randomString.js";
25
+ import { secureString as w } from "./string/secureString.js";
26
+ export { e as arraysIntersection, o as asyncResult, a as asyncify, S as capitalize, c as clamp, l as debounce, _ as findObjectKey, f as floor, v as getObjectKey, t as groupArrayItems, p as lerp, u as noop, y as objectForEach, b as omitObjectProperties, x as omitUndefinedObjectValues, n as randomArrayItem, h as randomInt, m as randomNumber, C as randomString, g as round, w as secureString, s as sleep, r as subtractArrays, d as throttle, i as uniquify };
@@ -1,4 +1,4 @@
1
- const n = (t, a, m) => Math.min(Math.max(t, a), m);
2
- export {
3
- n as clamp
4
- };
1
+ //#region src/number/clamp.ts
2
+ var e = (e, t, n) => Math.min(Math.max(e, t), n);
3
+ //#endregion
4
+ export { e as clamp };
@@ -1,4 +1,4 @@
1
- const t = (r, o = 0) => Math.floor(r * 10 ** o) / 10 ** o;
2
- export {
3
- t as floor
4
- };
1
+ //#region src/number/floor.ts
2
+ var e = (e, t = 0) => Math.floor(e * 10 ** t) / 10 ** t;
3
+ //#endregion
4
+ export { e as floor };
@@ -1,4 +1,4 @@
1
- const n = (e, t, r) => (1 - r) * e + r * t;
2
- export {
3
- n as lerp
4
- };
1
+ //#region src/number/lerp.ts
2
+ var e = (e, t, n) => (1 - n) * e + n * t;
3
+ //#endregion
4
+ export { e as lerp };
@@ -1,5 +1,5 @@
1
- import { randomNumber as n } from "./randomNumber.js";
2
- const t = (r = 0, o = 999999) => n(r, o, { precision: 0 });
3
- export {
4
- t as randomInt
5
- };
1
+ import { randomNumber as e } from "./randomNumber.js";
2
+ //#region src/number/randomInt.ts
3
+ var t = (t = 0, n = 999999) => e(t, n, { precision: 0 });
4
+ //#endregion
5
+ export { t as randomInt };
@@ -1,8 +1,8 @@
1
1
  import { floor as e } from "./floor.js";
2
- const a = (o = 0, r = 999999, t = {}) => {
3
- const { precision: n = 2 } = t;
4
- return e(Math.random() * (r - o + 1), n) + o;
5
- };
6
- export {
7
- a as randomNumber
2
+ //#region src/number/randomNumber.ts
3
+ var t = (t = 0, n = 999999, r = {}) => {
4
+ let { precision: i = 2 } = r;
5
+ return e(Math.random() * (n - t + 1), i) + t;
8
6
  };
7
+ //#endregion
8
+ export { t as randomNumber };
@@ -1,4 +1,4 @@
1
- const n = (t, r = 0) => Math.round(t * 10 ** r) / 10 ** r;
2
- export {
3
- n as round
4
- };
1
+ //#region src/number/round.ts
2
+ var e = (e, t = 0) => Math.round(e * 10 ** t) / 10 ** t;
3
+ //#endregion
4
+ export { e as round };
@@ -1,4 +1,4 @@
1
- const r = (e, t) => Object.entries(e).find(([, n]) => t(n))?.[0];
2
- export {
3
- r as findObjectKey
4
- };
1
+ //#region src/object/findObjectKey.ts
2
+ var e = (e, t) => Object.entries(e).find(([, e]) => t(e))?.[0];
3
+ //#endregion
4
+ export { e as findObjectKey };
@@ -1,5 +1,5 @@
1
- import { findObjectKey as o } from "./findObjectKey.js";
2
- const n = (e, t) => o(e, (r) => r === t);
3
- export {
4
- n as getObjectKey
5
- };
1
+ import { findObjectKey as e } from "./findObjectKey.js";
2
+ //#region src/object/getObjectKey.ts
3
+ var t = (t, n) => e(t, (e) => e === n);
4
+ //#endregion
5
+ export { t as getObjectKey };
@@ -1,9 +1,12 @@
1
- const a = (c, t) => {
2
- Object.keys(c).forEach((o) => {
3
- const e = c[o];
4
- t({ key: o, value: e });
5
- });
6
- };
7
- export {
8
- a as objectForEach
1
+ //#region src/object/objectForEach.ts
2
+ var e = (e, t) => {
3
+ Object.keys(e).forEach((n) => {
4
+ let r = e[n];
5
+ t({
6
+ key: n,
7
+ value: r
8
+ });
9
+ });
9
10
  };
11
+ //#endregion
12
+ export { e as objectForEach };
@@ -1,10 +1,10 @@
1
- import { objectForEach as c } from "./objectForEach.js";
2
- const a = (i, r) => {
3
- const o = {};
4
- return c(i, ({ key: t, value: e }) => {
5
- (Array.isArray(r) ? r.some((n) => String(n) === t) : String(r) === t) || (o[t] = e);
6
- }), o;
7
- };
8
- export {
9
- a as omitObjectProperties
1
+ import { objectForEach as e } from "./objectForEach.js";
2
+ //#region src/object/omitObjectProperties.ts
3
+ var t = (t, n) => {
4
+ let r = {};
5
+ return e(t, ({ key: e, value: t }) => {
6
+ (Array.isArray(n) ? n.some((t) => String(t) === e) : String(n) === e) || (r[e] = t);
7
+ }), r;
10
8
  };
9
+ //#endregion
10
+ export { t as omitObjectProperties };
@@ -1,10 +1,10 @@
1
- import { objectForEach as c } from "./objectForEach.js";
2
- const n = (e) => {
3
- const o = {};
4
- return c(e, ({ key: r, value: t }) => {
5
- t !== void 0 && (o[r] = t);
6
- }), o;
7
- };
8
- export {
9
- n as omitUndefinedObjectValues
1
+ import { objectForEach as e } from "./objectForEach.js";
2
+ //#region src/object/omitUndefinedObjectValues.ts
3
+ var t = (t) => {
4
+ let n = {};
5
+ return e(t, ({ key: e, value: t }) => {
6
+ t !== void 0 && (n[e] = t);
7
+ }), n;
10
8
  };
9
+ //#endregion
10
+ export { t as omitUndefinedObjectValues };
@@ -1,4 +1,4 @@
1
- const t = (e) => e.charAt(0).toUpperCase() + e.slice(1);
2
- export {
3
- t as capitalize
4
- };
1
+ //#region src/string/capitalize.ts
2
+ var e = (e) => e.charAt(0).toUpperCase() + e.slice(1);
3
+ //#endregion
4
+ export { e as capitalize };
@@ -1,19 +1,44 @@
1
- import { randomArrayItem as a } from "../array/randomArrayItem.js";
2
- import { randomInt as m } from "../number/randomInt.js";
3
- const p = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"], i = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"], l = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], u = ["!", "#", "@", "~", "$", "^", ".", ",", "-", "+", "%", "?", "*", "="], d = {
4
- 1: p,
5
- 2: i,
6
- 3: l,
7
- 4: u
8
- }, g = (t = {}) => {
9
- const { length: n = 16 } = t;
10
- let o = "";
11
- for (let r = 0; r < n; r++) {
12
- const s = m(1, 4), c = d[s], e = a(c);
13
- o += e;
14
- }
15
- return o;
16
- };
17
- export {
18
- g as randomString
1
+ import { randomArrayItem as e } from "../array/randomArrayItem.js";
2
+ import { randomInt as t } from "../number/randomInt.js";
3
+ //#region src/string/randomString.ts
4
+ var n = {
5
+ 1: /* @__PURE__ */ "abcdefghijklmnopqrstuvwxyz".split(""),
6
+ 2: /* @__PURE__ */ "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""),
7
+ 3: [
8
+ "0",
9
+ "1",
10
+ "2",
11
+ "3",
12
+ "4",
13
+ "5",
14
+ "6",
15
+ "7",
16
+ "8",
17
+ "9"
18
+ ],
19
+ 4: [
20
+ "!",
21
+ "#",
22
+ "@",
23
+ "~",
24
+ "$",
25
+ "^",
26
+ ".",
27
+ ",",
28
+ "-",
29
+ "+",
30
+ "%",
31
+ "?",
32
+ "*",
33
+ "="
34
+ ]
35
+ }, r = (r = {}) => {
36
+ let { length: i = 16 } = r, a = "";
37
+ for (let r = 0; r < i; r++) {
38
+ let r = n[t(1, 4)], i = e(r);
39
+ a += i;
40
+ }
41
+ return a;
19
42
  };
43
+ //#endregion
44
+ export { r as randomString };
@@ -1,10 +1,9 @@
1
- const s = (e, n = {}) => {
2
- const { maxInsecureChars: r = 4 } = n, t = "****";
3
- if (!e)
4
- return e;
5
- const c = Math.min(Math.floor(e.length / 2), r), a = e.slice(e.length - c);
6
- return `${t}${a}`;
7
- };
8
- export {
9
- s as secureString
1
+ //#region src/string/secureString.ts
2
+ var e = (e, t = {}) => {
3
+ let { maxInsecureChars: n = 4 } = t;
4
+ if (!e) return e;
5
+ let r = Math.min(Math.floor(e.length / 2), n);
6
+ return `****${e.slice(e.length - r)}`;
10
7
  };
8
+ //#endregion
9
+ export { e as secureString };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aliexme/js-utils",
3
- "version": "2.4.1",
3
+ "version": "3.0.0",
4
4
  "private": false,
5
5
  "description": "Common JavaScript utilities",
6
6
  "homepage": "https://github.com/aliexme/web-shared/tree/main/packages/js-utils",
@@ -14,12 +14,9 @@
14
14
  "sideEffects": false,
15
15
  "type": "module",
16
16
  "exports": {
17
- ".": {
18
- "import": "./dist/index.js",
19
- "require": "./dist/index.cjs"
20
- }
17
+ ".": "./dist/index.js"
21
18
  },
22
- "main": "./dist/index.cjs",
19
+ "main": "./dist/index.js",
23
20
  "module": "./dist/index.js",
24
21
  "types": "./dist/index.d.ts",
25
22
  "files": [
@@ -32,5 +29,5 @@
32
29
  "publishConfig": {
33
30
  "access": "public"
34
31
  },
35
- "gitHead": "1d314fb2f9ed2802b1ca152cedff0b0ee853e6dd"
32
+ "gitHead": "c32af348e1669e9dca51811a810abff6ba7de279"
36
33
  }
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(n,o,...r){if(n.length===0||o.length===0||r.some(t=>t.length===0))return[];const e=new Set(n),s=[o,...r];for(const t of s)for(const i of e)t.includes(i)||e.delete(i);return Array.from(e)}exports.arraysIntersection=c;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=(s,u)=>{const e={};return s.forEach(r=>{const t=r[u],o=e[t];o?o.push(r):e[t]=[r]}),e};exports.groupArrayItems=a;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=t=>{const r=Math.floor(Math.random()*t.length);return t[r]};exports.randomArrayItem=e;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(t,e,...r){if(t.length===0)return[];if(e.length===0)return[...t];const n=[e,...r],s=new Set(n.flat());return t.filter(u=>!s.has(u))}exports.subtractArrays=c;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=e=>[...new Set(e)];exports.uniquify=t;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./asyncify.cjs"),e=n=>s.asyncify(n)();exports.asyncResult=e;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=e=>(...t)=>new Promise(r=>{setTimeout(()=>r(e(...t)),0)});exports.asyncify=n;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=async e=>new Promise(t=>setTimeout(t,e));exports.sleep=s;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../number/clamp.cjs"),C=(l,c,m={})=>{const{maxWait:i,withLeading:d=!1}=m;let e=null,t=null;const o=()=>{e!==null&&(clearTimeout(e),e=null)},n=()=>{t=null},T=()=>{o(),n()},s=(...r)=>{o();const u=Date.now(),b=t?u-t:0,a=i?f.clamp(i-b,0,c):c;if(!t&&(t=u,d)){l(...r),e=setTimeout(n,a);return}e=setTimeout(()=>{l(...r),n()},a)};return s.cancel=T,s};exports.debounce=C;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=()=>{};exports.noop=o;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=(n,r,s={})=>{const{withTrailing:T=!1}=s;let e=null,t=null,l=!1;const o=()=>{e!==null&&(clearTimeout(e),e=null)},a=()=>{t!==null&&(clearTimeout(t),t=null)},c=()=>{l=!1},m=()=>{o(),a(),c()},i=(...u)=>{if(l){T&&(o(),e=setTimeout(()=>n(...u),r));return}o(),n(...u),l=!0,t=setTimeout(c,r)};return i.cancel=m,i};exports.throttle=d;
package/dist/index.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./array/arraysIntersection.cjs"),r=require("./async/asyncResult.cjs"),t=require("./async/asyncify.cjs"),o=require("./string/capitalize.cjs"),n=require("./number/clamp.cjs"),c=require("./function/debounce.cjs"),i=require("./object/findObjectKey.cjs"),s=require("./number/floor.cjs"),u=require("./object/getObjectKey.cjs"),a=require("./array/groupArrayItems.cjs"),y=require("./number/lerp.cjs"),m=require("./function/noop.cjs"),d=require("./object/objectForEach.cjs"),q=require("./object/omitObjectProperties.cjs"),l=require("./object/omitUndefinedObjectValues.cjs"),b=require("./array/randomArrayItem.cjs"),p=require("./number/randomInt.cjs"),f=require("./number/randomNumber.cjs"),j=require("./string/randomString.cjs"),g=require("./number/round.cjs"),O=require("./string/secureString.cjs"),I=require("./async/sleep.cjs"),A=require("./array/subtractArrays.cjs"),S=require("./function/throttle.cjs"),h=require("./array/uniquify.cjs");exports.arraysIntersection=e.arraysIntersection;exports.asyncResult=r.asyncResult;exports.asyncify=t.asyncify;exports.capitalize=o.capitalize;exports.clamp=n.clamp;exports.debounce=c.debounce;exports.findObjectKey=i.findObjectKey;exports.floor=s.floor;exports.getObjectKey=u.getObjectKey;exports.groupArrayItems=a.groupArrayItems;exports.lerp=y.lerp;exports.noop=m.noop;exports.objectForEach=d.objectForEach;exports.omitObjectProperties=q.omitObjectProperties;exports.omitUndefinedObjectValues=l.omitUndefinedObjectValues;exports.randomArrayItem=b.randomArrayItem;exports.randomInt=p.randomInt;exports.randomNumber=f.randomNumber;exports.randomString=j.randomString;exports.round=g.round;exports.secureString=O.secureString;exports.sleep=I.sleep;exports.subtractArrays=A.subtractArrays;exports.throttle=S.throttle;exports.uniquify=h.uniquify;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=(t,e,a)=>Math.min(Math.max(t,e),a);exports.clamp=r;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=(t,o=0)=>Math.floor(t*10**o)/10**o;exports.floor=r;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=(r,t,e)=>(1-e)*r+e*t;exports.lerp=o;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./randomNumber.cjs"),o=(r=0,e=999999)=>n.randomNumber(r,e,{precision:0});exports.randomInt=o;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./floor.cjs"),u=(r=0,o=999999,e={})=>{const{precision:t=2}=e;return n.floor(Math.random()*(o-r+1),t)+r};exports.randomNumber=u;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=(r,t=0)=>Math.round(r*10**t)/10**t;exports.round=e;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=(e,t)=>Object.entries(e).find(([,n])=>t(n))?.[0];exports.findObjectKey=i;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./findObjectKey.cjs"),n=(e,t)=>r.findObjectKey(e,c=>c===t);exports.getObjectKey=n;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=(e,c)=>{Object.keys(e).forEach(t=>{const o=e[t];c({key:t,value:o})})};exports.objectForEach=r;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./objectForEach.cjs"),s=(o,t)=>{const e={};return n.objectForEach(o,({key:r,value:i})=>{(Array.isArray(t)?t.some(c=>String(c)===r):String(t)===r)||(e[r]=i)}),e};exports.omitObjectProperties=s;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./objectForEach.cjs"),i=o=>{const e={};return r.objectForEach(o,({key:c,value:t})=>{t!==void 0&&(e[c]=t)}),e};exports.omitUndefinedObjectValues=i;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=e=>e.charAt(0).toUpperCase()+e.slice(1);exports.capitalize=t;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../array/randomArrayItem.cjs"),u=require("../number/randomInt.cjs"),d=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],i=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],m=["0","1","2","3","4","5","6","7","8","9"],l=["!","#","@","~","$","^",".",",","-","+","%","?","*","="],p={1:d,2:i,3:m,4:l},g=(o={})=>{const{length:n=16}=o;let r="";for(let t=0;t<n;t++){const e=u.randomInt(1,4),s=p[e],c=a.randomArrayItem(s);r+=c}return r};exports.randomString=g;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=(e,n={})=>{const{maxInsecureChars:r=4}=n,t="****";if(!e)return e;const c=Math.min(Math.floor(e.length/2),r),s=e.slice(e.length-c);return`${t}${s}`};exports.secureString=a;