@aliexme/js-utils 2.1.2 → 2.2.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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=(n,i,...r)=>{if(n.length===0||i.length===0||r.some(e=>e.length===0))return[];let t=n.filter(e=>i.includes(e));return r.forEach(e=>{t=t.filter(l=>e.includes(l))}),t};exports.arraysIntersection=o;
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 +1 @@
1
- export declare const arraysIntersection: <T>(array1: T[], array2: T[], ...arrays: T[][]) => T[];
1
+ export declare function arraysIntersection<T>(array1: T[], array2: T[], ...restArrays: T[][]): T[];
@@ -1,10 +1,11 @@
1
- const o = (n, i, ...l) => {
2
- if (n.length === 0 || i.length === 0 || l.some((e) => e.length === 0)) return [];
3
- let t = n.filter((e) => i.includes(e));
4
- return l.forEach((e) => {
5
- t = t.filter((c) => e.includes(c));
6
- }), t;
7
- };
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);
8
+ }
8
9
  export {
9
- o as arraysIntersection
10
+ i as arraysIntersection
10
11
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=(t,e)=>t.length===0||e.length===0?t:t.filter(r=>!e.includes(r));exports.subtractArrays=n;
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 +1 @@
1
- export declare const subtractArrays: <T>(array1: T[], array2: T[]) => T[];
1
+ export declare function subtractArrays<T>(mainArray: T[], arrayToSubstract: T[], ...restArraysToSubtract: T[][]): T[];
@@ -1,4 +1,9 @@
1
- const l = (t, e) => t.length === 0 || e.length === 0 ? t : t.filter((n) => !e.includes(n));
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));
6
+ }
2
7
  export {
3
- l as subtractArrays
8
+ c as subtractArrays
4
9
  };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./string/capitalize.cjs"),r=require("./string/secureString.cjs"),t=require("./string/randomString.cjs"),n=require("./number/round.cjs"),o=require("./number/clamp.cjs"),c=require("./number/randomInt.cjs"),i=require("./array/uniquify.cjs"),s=require("./array/subtractArrays.cjs"),u=require("./array/arraysIntersection.cjs"),a=require("./array/groupArrayItems.cjs"),y=require("./array/randomArrayItem.cjs"),d=require("./object/getObjectKey.cjs"),m=require("./object/findObjectKey.cjs"),q=require("./object/objectForEach.cjs"),b=require("./object/omitObjectProperties.cjs"),l=require("./object/omitUndefinedObjectValues.cjs"),p=require("./function/noop.cjs"),j=require("./function/debounce.cjs"),g=require("./function/throttle.cjs"),f=require("./async/asyncify.cjs"),O=require("./async/asyncResult.cjs"),I=require("./async/sleep.cjs");exports.capitalize=e.capitalize;exports.secureString=r.secureString;exports.randomString=t.randomString;exports.round=n.round;exports.clamp=o.clamp;exports.randomInt=c.randomInt;exports.uniquify=i.uniquify;exports.subtractArrays=s.subtractArrays;exports.arraysIntersection=u.arraysIntersection;exports.groupArrayItems=a.groupArrayItems;exports.randomArrayItem=y.randomArrayItem;exports.getObjectKey=d.getObjectKey;exports.findObjectKey=m.findObjectKey;exports.objectForEach=q.objectForEach;exports.omitObjectProperties=b.omitObjectProperties;exports.omitUndefinedObjectValues=l.omitUndefinedObjectValues;exports.noop=p.noop;exports.debounce=j.debounce;exports.throttle=g.throttle;exports.asyncify=f.asyncify;exports.asyncResult=O.asyncResult;exports.sleep=I.sleep;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./string/capitalize.cjs"),r=require("./string/secureString.cjs"),t=require("./string/randomString.cjs"),o=require("./number/round.cjs"),n=require("./number/floor.cjs"),c=require("./number/clamp.cjs"),i=require("./number/randomNumber.cjs"),s=require("./number/randomInt.cjs"),u=require("./array/uniquify.cjs"),a=require("./array/subtractArrays.cjs"),y=require("./array/arraysIntersection.cjs"),m=require("./array/groupArrayItems.cjs"),d=require("./array/randomArrayItem.cjs"),q=require("./object/getObjectKey.cjs"),b=require("./object/findObjectKey.cjs"),l=require("./object/objectForEach.cjs"),p=require("./object/omitObjectProperties.cjs"),f=require("./object/omitUndefinedObjectValues.cjs"),j=require("./function/noop.cjs"),g=require("./function/debounce.cjs"),O=require("./function/throttle.cjs"),I=require("./async/asyncify.cjs"),A=require("./async/asyncResult.cjs"),S=require("./async/sleep.cjs");exports.capitalize=e.capitalize;exports.secureString=r.secureString;exports.randomString=t.randomString;exports.round=o.round;exports.floor=n.floor;exports.clamp=c.clamp;exports.randomNumber=i.randomNumber;exports.randomInt=s.randomInt;exports.uniquify=u.uniquify;exports.subtractArrays=a.subtractArrays;exports.arraysIntersection=y.arraysIntersection;exports.groupArrayItems=m.groupArrayItems;exports.randomArrayItem=d.randomArrayItem;exports.getObjectKey=q.getObjectKey;exports.findObjectKey=b.findObjectKey;exports.objectForEach=l.objectForEach;exports.omitObjectProperties=p.omitObjectProperties;exports.omitUndefinedObjectValues=f.omitUndefinedObjectValues;exports.noop=j.noop;exports.debounce=g.debounce;exports.throttle=O.throttle;exports.asyncify=I.asyncify;exports.asyncResult=A.asyncResult;exports.sleep=S.sleep;
package/dist/index.js CHANGED
@@ -2,45 +2,49 @@ import { capitalize as e } from "./string/capitalize.js";
2
2
  import { secureString as m } from "./string/secureString.js";
3
3
  import { randomString as f } from "./string/randomString.js";
4
4
  import { round as n } from "./number/round.js";
5
- import { clamp as c } from "./number/clamp.js";
6
- import { randomInt as s } from "./number/randomInt.js";
7
- import { uniquify as u } from "./array/uniquify.js";
8
- import { subtractArrays as b } from "./array/subtractArrays.js";
9
- import { arraysIntersection as j } from "./array/arraysIntersection.js";
10
- import { groupArrayItems as I } from "./array/groupArrayItems.js";
11
- import { randomArrayItem as A } from "./array/randomArrayItem.js";
12
- import { getObjectKey as K } from "./object/getObjectKey.js";
13
- import { findObjectKey as q } from "./object/findObjectKey.js";
14
- import { objectForEach as E } from "./object/objectForEach.js";
15
- import { omitObjectProperties as P } from "./object/omitObjectProperties.js";
16
- import { omitUndefinedObjectValues as U } from "./object/omitUndefinedObjectValues.js";
17
- import { noop as k } from "./function/noop.js";
18
- import { debounce as w } from "./function/debounce.js";
19
- import { throttle as C } from "./function/throttle.js";
20
- import { asyncify as G } from "./async/asyncify.js";
21
- import { asyncResult as J } from "./async/asyncResult.js";
22
- import { sleep as M } from "./async/sleep.js";
5
+ import { floor as c } from "./number/floor.js";
6
+ import { clamp as s } from "./number/clamp.js";
7
+ import { randomNumber as y } from "./number/randomNumber.js";
8
+ import { randomInt as b } from "./number/randomInt.js";
9
+ import { uniquify as j } from "./array/uniquify.js";
10
+ import { subtractArrays as I } from "./array/subtractArrays.js";
11
+ import { arraysIntersection as A } from "./array/arraysIntersection.js";
12
+ import { groupArrayItems as K } from "./array/groupArrayItems.js";
13
+ import { randomArrayItem as q } from "./array/randomArrayItem.js";
14
+ import { getObjectKey as E } from "./object/getObjectKey.js";
15
+ import { findObjectKey as N } from "./object/findObjectKey.js";
16
+ import { objectForEach as R } from "./object/objectForEach.js";
17
+ import { omitObjectProperties as V } from "./object/omitObjectProperties.js";
18
+ import { omitUndefinedObjectValues as v } from "./object/omitUndefinedObjectValues.js";
19
+ import { noop as B } from "./function/noop.js";
20
+ import { debounce as D } from "./function/debounce.js";
21
+ import { throttle as H } from "./function/throttle.js";
22
+ import { asyncify as L } from "./async/asyncify.js";
23
+ import { asyncResult as Q } from "./async/asyncResult.js";
24
+ import { sleep as W } from "./async/sleep.js";
23
25
  export {
24
- j as arraysIntersection,
25
- J as asyncResult,
26
- G as asyncify,
26
+ A as arraysIntersection,
27
+ Q as asyncResult,
28
+ L as asyncify,
27
29
  e as capitalize,
28
- c as clamp,
29
- w as debounce,
30
- q as findObjectKey,
31
- K as getObjectKey,
32
- I as groupArrayItems,
33
- k as noop,
34
- E as objectForEach,
35
- P as omitObjectProperties,
36
- U as omitUndefinedObjectValues,
37
- A as randomArrayItem,
38
- s as randomInt,
30
+ s as clamp,
31
+ D as debounce,
32
+ N as findObjectKey,
33
+ c as floor,
34
+ E as getObjectKey,
35
+ K as groupArrayItems,
36
+ B as noop,
37
+ R as objectForEach,
38
+ V as omitObjectProperties,
39
+ v as omitUndefinedObjectValues,
40
+ q as randomArrayItem,
41
+ b as randomInt,
42
+ y as randomNumber,
39
43
  f as randomString,
40
44
  n as round,
41
45
  m as secureString,
42
- M as sleep,
43
- b as subtractArrays,
44
- C as throttle,
45
- u as uniquify
46
+ W as sleep,
47
+ I as subtractArrays,
48
+ H as throttle,
49
+ j as uniquify
46
50
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=(t,o=0)=>Math.floor(t*Math.pow(10,o))/Math.pow(10,o);exports.floor=r;
@@ -0,0 +1 @@
1
+ export declare const floor: (value: number, precision?: number) => number;
@@ -0,0 +1,4 @@
1
+ const r = (t, o = 0) => Math.floor(t * Math.pow(10, o)) / Math.pow(10, o);
2
+ export {
3
+ r as floor
4
+ };
@@ -1,3 +1,5 @@
1
1
  export * from './round';
2
+ export * from './floor';
2
3
  export * from './clamp';
4
+ export * from './randomNumber';
3
5
  export * from './randomInt';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=(t=0,n=999999)=>Math.floor(Math.random()*(n-t+1))+t;exports.randomInt=o;
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 +1 @@
1
- export declare const randomInt: (from?: number, to?: number) => number;
1
+ export declare const randomInt: (min?: number, max?: number) => number;
@@ -1,4 +1,5 @@
1
- const o = (t = 0, n = 999999) => Math.floor(Math.random() * (n - t + 1)) + t;
1
+ import { randomNumber as n } from "./randomNumber.js";
2
+ const t = (r = 0, o = 999999) => n(r, o, { precision: 0 });
2
3
  export {
3
- o as randomInt
4
+ t as randomInt
4
5
  };
@@ -0,0 +1 @@
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;
@@ -0,0 +1,4 @@
1
+ export interface RandomNumberOptions {
2
+ precision?: number;
3
+ }
4
+ export declare const randomNumber: (min?: number, max?: number, options?: RandomNumberOptions) => number;
@@ -0,0 +1,8 @@
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
8
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=(t,r={})=>{const{precision:o=0}=r;return Math.round(t*Math.pow(10,o))/Math.pow(10,o)};exports.round=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=(o,t=0)=>Math.round(o*Math.pow(10,t))/Math.pow(10,t);exports.round=r;
@@ -1,3 +1 @@
1
- export declare const round: (value: number, options?: {
2
- precision?: number;
3
- }) => number;
1
+ export declare const round: (value: number, precision?: number) => number;
@@ -1,7 +1,4 @@
1
- const r = (t, n = {}) => {
2
- const { precision: o = 0 } = n;
3
- return Math.round(t * Math.pow(10, o)) / Math.pow(10, o);
4
- };
1
+ const r = (o, t = 0) => Math.round(o * Math.pow(10, t)) / Math.pow(10, t);
5
2
  export {
6
3
  r as round
7
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aliexme/js-utils",
3
- "version": "2.1.2",
3
+ "version": "2.2.0",
4
4
  "description": "Common JavaScript utilities",
5
5
  "private": false,
6
6
  "author": "Alexander Smirnov <al.smirnov996@gmail.com>",
@@ -32,5 +32,5 @@
32
32
  "build": "vite build",
33
33
  "ts:check": "tsc --noEmit"
34
34
  },
35
- "gitHead": "b8a504e726d4d9ee140e45a422168e491bf6f984"
35
+ "gitHead": "28e586ee30ce923e8d24211730f60d5490e1beb8"
36
36
  }