@untemps/utils 2.5.0 → 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 (85) hide show
  1. package/dist/array/extractByIndices.cjs +1 -0
  2. package/dist/array/extractByIndices.js +4 -0
  3. package/dist/async/standby.cjs +1 -0
  4. package/dist/async/standby.js +4 -0
  5. package/dist/dom/createElement.cjs +1 -0
  6. package/dist/dom/createElement.js +19 -0
  7. package/dist/dom/doElementsOverlap.cjs +1 -0
  8. package/dist/dom/doElementsOverlap.js +7 -0
  9. package/dist/dom/getCSSDeclaration.cjs +1 -0
  10. package/dist/dom/getCSSDeclaration.js +13 -0
  11. package/dist/dom/getElement.cjs +1 -0
  12. package/dist/dom/getElement.js +4 -0
  13. package/dist/dom/isElement.cjs +1 -0
  14. package/dist/dom/isElement.js +4 -0
  15. package/dist/dom/modifyElement.cjs +1 -0
  16. package/dist/dom/modifyElement.js +11 -0
  17. package/dist/dom/removeElement.cjs +1 -0
  18. package/dist/dom/removeElement.js +9 -0
  19. package/dist/dom/resolveClassName.cjs +1 -0
  20. package/dist/dom/resolveClassName.js +10 -0
  21. package/dist/function/isFunction.cjs +1 -0
  22. package/dist/function/isFunction.js +4 -0
  23. package/dist/lang/isNil.cjs +1 -0
  24. package/dist/lang/isNil.js +4 -0
  25. package/dist/number/getRandomInteger.cjs +1 -0
  26. package/dist/number/getRandomInteger.js +8 -0
  27. package/dist/number/normalizeMinMax.cjs +1 -0
  28. package/dist/number/normalizeMinMax.js +7 -0
  29. package/dist/object/deepMerge.cjs +1 -0
  30. package/dist/object/deepMerge.js +9 -0
  31. package/dist/object/isObject.cjs +1 -0
  32. package/dist/object/isObject.js +4 -0
  33. package/dist/string/generateText.cjs +1 -0
  34. package/dist/string/generateText.js +71 -0
  35. package/dist/string/generateTokenizedText.cjs +1 -0
  36. package/dist/string/generateTokenizedText.js +27 -0
  37. package/dist/string/interpolate.cjs +1 -0
  38. package/dist/string/interpolate.js +14 -0
  39. package/dist/string/interpolateLiteral.cjs +1 -0
  40. package/dist/string/interpolateLiteral.js +4 -0
  41. package/dist/string/isString.cjs +1 -0
  42. package/dist/string/isString.js +4 -0
  43. package/package.json +13 -30
  44. package/dist/cjs/array/extractByIndices.js +0 -1
  45. package/dist/cjs/async/standby.js +0 -1
  46. package/dist/cjs/dom/createElement.js +0 -1
  47. package/dist/cjs/dom/doElementsOverlap.js +0 -1
  48. package/dist/cjs/dom/getCSSDeclaration.js +0 -1
  49. package/dist/cjs/dom/getElement.js +0 -1
  50. package/dist/cjs/dom/isElement.js +0 -1
  51. package/dist/cjs/dom/modifyElement.js +0 -1
  52. package/dist/cjs/dom/removeElement.js +0 -1
  53. package/dist/cjs/dom/resolveClassName.js +0 -1
  54. package/dist/cjs/function/isFunction.js +0 -1
  55. package/dist/cjs/lang/isNil.js +0 -1
  56. package/dist/cjs/number/getRandomInteger.js +0 -1
  57. package/dist/cjs/number/normalizeMinMax.js +0 -1
  58. package/dist/cjs/object/deepMerge.js +0 -1
  59. package/dist/cjs/object/isObject.js +0 -1
  60. package/dist/cjs/string/generateText.js +0 -1
  61. package/dist/cjs/string/generateTokenizedText.js +0 -1
  62. package/dist/cjs/string/interpolate.js +0 -1
  63. package/dist/cjs/string/interpolateLiteral.js +0 -1
  64. package/dist/cjs/string/isString.js +0 -1
  65. package/dist/esm/array/extractByIndices.js +0 -1
  66. package/dist/esm/async/standby.js +0 -1
  67. package/dist/esm/dom/createElement.js +0 -1
  68. package/dist/esm/dom/doElementsOverlap.js +0 -1
  69. package/dist/esm/dom/getCSSDeclaration.js +0 -1
  70. package/dist/esm/dom/getElement.js +0 -1
  71. package/dist/esm/dom/isElement.js +0 -1
  72. package/dist/esm/dom/modifyElement.js +0 -1
  73. package/dist/esm/dom/removeElement.js +0 -1
  74. package/dist/esm/dom/resolveClassName.js +0 -1
  75. package/dist/esm/function/isFunction.js +0 -1
  76. package/dist/esm/lang/isNil.js +0 -1
  77. package/dist/esm/number/getRandomInteger.js +0 -1
  78. package/dist/esm/number/normalizeMinMax.js +0 -1
  79. package/dist/esm/object/deepMerge.js +0 -1
  80. package/dist/esm/object/isObject.js +0 -1
  81. package/dist/esm/string/generateText.js +0 -1
  82. package/dist/esm/string/generateTokenizedText.js +0 -1
  83. package/dist/esm/string/interpolate.js +0 -1
  84. package/dist/esm/string/interpolateLiteral.js +0 -1
  85. package/dist/esm/string/isString.js +0 -1
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=(t,e)=>(t==null?void 0:t.filter((y,l)=>e==null?void 0:e.includes(l)))??[];exports.extractByIndices=a;
@@ -0,0 +1,4 @@
1
+ const f = (t, l) => (t == null ? void 0 : t.filter((a, x) => l == null ? void 0 : l.includes(x))) ?? [];
2
+ export {
3
+ f as extractByIndices
4
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=(e=128)=>new Promise(t=>setTimeout(t,e));exports.standby=o;
@@ -0,0 +1,4 @@
1
+ const o = (e = 128) => new Promise((t) => setTimeout(t, e));
2
+ export {
3
+ o as standby
4
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=({tag:o="div",attributes:l={},content:t=null,textContent:n=null,parent:u=null,parentSelector:c=null,boundingClientRect:d=null}={})=>{const e=document.createElement(o);for(let i in l)e.setAttribute(i,l[i]);t&&e.appendChild(t),n&&!e.hasChildNodes()&&e.appendChild(document.createTextNode(n));const r=u||document.querySelector(c);return r&&r.appendChild(e),d&&(e.getBoundingClientRect=()=>d),e};exports.createElement=a;
@@ -0,0 +1,19 @@
1
+ const p = ({
2
+ tag: r = "div",
3
+ attributes: l = {},
4
+ content: n = null,
5
+ textContent: d = null,
6
+ parent: u = null,
7
+ parentSelector: c = null,
8
+ boundingClientRect: t = null
9
+ } = {}) => {
10
+ const e = document.createElement(r);
11
+ for (let o in l)
12
+ e.setAttribute(o, l[o]);
13
+ n && e.appendChild(n), d && !e.hasChildNodes() && e.appendChild(document.createTextNode(d));
14
+ const i = u || document.querySelector(c);
15
+ return i && i.appendChild(e), t && (e.getBoundingClientRect = () => t), e;
16
+ };
17
+ export {
18
+ p as createElement
19
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=(t,e)=>{const{left:o,right:n,top:l,bottom:r}=t.getBoundingClientRect(),{left:i,right:g,top:c,bottom:m}=e.getBoundingClientRect();return!(l>m||n<i||r<c||o>g)};exports.doElementsOverlap=p;
@@ -0,0 +1,7 @@
1
+ const m = (t, o) => {
2
+ const { left: e, right: n, top: g, bottom: i } = t.getBoundingClientRect(), { left: l, right: r, top: p, bottom: c } = o.getBoundingClientRect();
3
+ return !(g > c || n < l || i < p || e > r);
4
+ };
5
+ export {
6
+ m as doElementsOverlap
7
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=(t,r=!1)=>{var o;if(t&&(t=t.startsWith(".")?t:`.${t}`,(o=document.styleSheets)!=null&&o.length)){for(let{cssRules:l}of document.styleSheets)for(let{selectorText:n,style:e}of l)if(n===t&&e)return r?e.cssText:e}return null};exports.getCSSDeclaration=f;
@@ -0,0 +1,13 @@
1
+ const l = (t, r = !1) => {
2
+ var o;
3
+ if (t && (t = t.startsWith(".") ? t : `.${t}`, (o = document.styleSheets) != null && o.length)) {
4
+ for (let { cssRules: f } of document.styleSheets)
5
+ for (let { selectorText: n, style: e } of f)
6
+ if (n === t && e)
7
+ return r ? e.cssText : e;
8
+ }
9
+ return null;
10
+ };
11
+ export {
12
+ l as getCSSDeclaration
13
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=e=>document.querySelector(e);exports.getElement=t;
@@ -0,0 +1,4 @@
1
+ const t = (e) => document.querySelector(e);
2
+ export {
3
+ t as getElement
4
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=e=>(e==null?void 0:e.nodeType)===1;exports.isElement=t;
@@ -0,0 +1,4 @@
1
+ const o = (n) => (n == null ? void 0 : n.nodeType) === 1;
2
+ export {
3
+ o as isElement
4
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../string/isString.cjs"),o=(t,r={})=>{let e=t;n.isString(t)&&(e=document.querySelector(t));for(let i in r)r[i]===void 0||r[i]===null?e==null||e.removeAttribute(i):e==null||e.setAttribute(i,r[i]);return e};exports.modifyElement=o;
@@ -0,0 +1,11 @@
1
+ import { isString as n } from "../string/isString.js";
2
+ const t = (i, e = {}) => {
3
+ let o = i;
4
+ n(i) && (o = document.querySelector(i));
5
+ for (let r in e)
6
+ e[r] === void 0 || e[r] === null ? o == null || o.removeAttribute(r) : o == null || o.setAttribute(r, e[r]);
7
+ return o;
8
+ };
9
+ export {
10
+ t as modifyElement
11
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../string/isString.cjs"),i=r=>{var t;let e=r;return o.isString(r)&&(e=document.querySelector(r)),(t=e==null?void 0:e.parentNode)==null?void 0:t.removeChild(e)};exports.removeElement=i;
@@ -0,0 +1,9 @@
1
+ import { isString as t } from "../string/isString.js";
2
+ const m = (o) => {
3
+ var e;
4
+ let r = o;
5
+ return t(o) && (r = document.querySelector(o)), (e = r == null ? void 0 : r.parentNode) == null ? void 0 : e.removeChild(r);
6
+ };
7
+ export {
8
+ m as removeElement
9
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=r=>r!=null&&r.length?r.reduce((o,e)=>{if(Array.isArray(e)){const[s,t,n]=e;e=s?t:n}return y(e)?[...o,e]:o},[]).join(" "):"",y=r=>r&&typeof r=="string"?r:null;exports.resolveClassName=l;
@@ -0,0 +1,10 @@
1
+ const f = (r) => r != null && r.length ? r.reduce((s, o) => {
2
+ if (Array.isArray(o)) {
3
+ const [e, n, t] = o;
4
+ o = e ? n : t;
5
+ }
6
+ return y(o) ? [...s, o] : s;
7
+ }, []).join(" ") : "", y = (r) => r && typeof r == "string" ? r : null;
8
+ export {
9
+ f as resolveClassName
10
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=t=>typeof t=="function";exports.isFunction=n;
@@ -0,0 +1,4 @@
1
+ const o = (n) => typeof n == "function";
2
+ export {
3
+ o as isFunction
4
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=e=>e==null;exports.isNil=i;
@@ -0,0 +1,4 @@
1
+ const i = (n) => n == null;
2
+ export {
3
+ i as isNil
4
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./normalizeMinMax.cjs"),o=(n=-Number.MAX_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER)=>{const{min:e,max:t}=m.normalizeMinMax(n,r);return Math.round(e+Math.random()*(t-e))};exports.getRandomInteger=o;
@@ -0,0 +1,8 @@
1
+ import { normalizeMinMax as t } from "./normalizeMinMax.js";
2
+ const a = (n = -Number.MAX_SAFE_INTEGER, r = Number.MAX_SAFE_INTEGER) => {
3
+ const { min: m, max: o } = t(n, r);
4
+ return Math.round(m + Math.random() * (o - m));
5
+ };
6
+ export {
7
+ a as getRandomInteger
8
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=(e,t)=>({min:Math.min(e,t),max:Math.max(e,t)});exports.normalizeMinMax=a;
@@ -0,0 +1,7 @@
1
+ const t = (a, n) => ({
2
+ min: Math.min(a, n),
3
+ max: Math.max(a, n)
4
+ });
5
+ export {
6
+ t as normalizeMinMax
7
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./isObject.cjs"),n=(e,t)=>{for(const i of Object.keys(e))b.isObject(e[i])&&i in t&&Object.assign(e[i],n(e[i],t[i]));return Object.assign(t||{},e),t};exports.deepMerge=n;
@@ -0,0 +1,9 @@
1
+ import { isObject as b } from "./isObject.js";
2
+ const f = (i, e) => {
3
+ for (const n of Object.keys(i))
4
+ b(i[n]) && n in e && Object.assign(i[n], f(i[n], e[n]));
5
+ return Object.assign(e || {}, i), e;
6
+ };
7
+ export {
8
+ f as deepMerge
9
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=t=>Object.getPrototypeOf(t)===Object.prototype;exports.isObject=e;
@@ -0,0 +1,4 @@
1
+ const e = (t) => Object.getPrototypeOf(t) === Object.prototype;
2
+ export {
3
+ e as isObject
4
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../number/getRandomInteger.cjs"),c=require("../number/normalizeMinMax.cjs"),g=["year","learn","key","cook","crosswalk","script","chief","plan","meat","vague","demonstrator","dictionary","visible","bomber","variation","leader","channel","litigation","royalty","impulse","package","oppose","privilege","begin","operation","herd","hemisphere","incongruous","horror","pipe","start","vertical","worry","reform","unlike","exhibition","disagree","allow","patrol","combine","impress","invisible","cage","log","snow","undertake","division","ethics","damage","responsible"],M=(r,a)=>{const{min:e,max:n}=c.normalizeMinMax(Math.abs(r),Math.abs(a)),t=Math.max(e,1),o=Math.max(n,t);return{min:t,max:o}},h=({minWords:r=10,maxWords:a=50,dictionary:e=g}={})=>{let n="";const{min:t,max:o}=M(r,a),s=m.getRandomInteger(t,o);for(let i=0;i<s;i++){const l=e[Math.floor(Math.random()*e.length)];n+=`${i>0?" ":""}${l}`}return n};exports.generateText=h;
@@ -0,0 +1,71 @@
1
+ import { getRandomInteger as m } from "../number/getRandomInteger.js";
2
+ import { normalizeMinMax as c } from "../number/normalizeMinMax.js";
3
+ const p = [
4
+ "year",
5
+ "learn",
6
+ "key",
7
+ "cook",
8
+ "crosswalk",
9
+ "script",
10
+ "chief",
11
+ "plan",
12
+ "meat",
13
+ "vague",
14
+ "demonstrator",
15
+ "dictionary",
16
+ "visible",
17
+ "bomber",
18
+ "variation",
19
+ "leader",
20
+ "channel",
21
+ "litigation",
22
+ "royalty",
23
+ "impulse",
24
+ "package",
25
+ "oppose",
26
+ "privilege",
27
+ "begin",
28
+ "operation",
29
+ "herd",
30
+ "hemisphere",
31
+ "incongruous",
32
+ "horror",
33
+ "pipe",
34
+ "start",
35
+ "vertical",
36
+ "worry",
37
+ "reform",
38
+ "unlike",
39
+ "exhibition",
40
+ "disagree",
41
+ "allow",
42
+ "patrol",
43
+ "combine",
44
+ "impress",
45
+ "invisible",
46
+ "cage",
47
+ "log",
48
+ "snow",
49
+ "undertake",
50
+ "division",
51
+ "ethics",
52
+ "damage",
53
+ "responsible"
54
+ ], g = (a, n) => {
55
+ const { min: e, max: o } = c(Math.abs(a), Math.abs(n)), t = Math.max(e, 1), r = Math.max(o, t);
56
+ return {
57
+ min: t,
58
+ max: r
59
+ };
60
+ }, x = ({ minWords: a = 10, maxWords: n = 50, dictionary: e = p } = {}) => {
61
+ let o = "";
62
+ const { min: t, max: r } = g(a, n), s = m(t, r);
63
+ for (let i = 0; i < s; i++) {
64
+ const l = e[Math.floor(Math.random() * e.length)];
65
+ o += `${i > 0 ? " " : ""}${l}`;
66
+ }
67
+ return o;
68
+ };
69
+ export {
70
+ x as generateText
71
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./generateText.cjs");require("../number/getRandomInteger.cjs");require("../number/normalizeMinMax.cjs");const x=({tokens:e=[],divider:r="%",minWords:i=10,maxWords:l=50,dictionary:g=void 0}={})=>{const n=s.generateText({minWords:Math.max(i,e.length),maxWords:Math.max(l,e.length),dictionary:g}).split(" "),o=Math.max(Math.floor((n.length-e.length)/e.length),1),a=[];for(let t=0;t<e.length;t++){const h=Math.floor(Math.random()*o)+o*t;n[h]=`${r}${e[t]}${r}`,a.push(h)}return{indices:a,text:n.join(" ")}};exports.generateTokenizedText=x;
@@ -0,0 +1,27 @@
1
+ import { generateText as m } from "./generateText.js";
2
+ import "../number/getRandomInteger.js";
3
+ import "../number/normalizeMinMax.js";
4
+ const p = ({
5
+ tokens: t = [],
6
+ divider: o = "%",
7
+ minWords: l = 10,
8
+ maxWords: x = 50,
9
+ dictionary: i = void 0
10
+ } = {}) => {
11
+ const n = m({
12
+ minWords: Math.max(l, t.length),
13
+ maxWords: Math.max(x, t.length),
14
+ dictionary: i
15
+ }).split(" "), r = Math.max(Math.floor((n.length - t.length) / t.length), 1), h = [];
16
+ for (let e = 0; e < t.length; e++) {
17
+ const a = Math.floor(Math.random() * r) + r * e;
18
+ n[a] = `${o}${t[e]}${o}`, h.push(a);
19
+ }
20
+ return {
21
+ indices: h,
22
+ text: n.join(" ")
23
+ };
24
+ };
25
+ export {
26
+ p as generateTokenizedText
27
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../lang/isNil.cjs"),p=n=>{const e=new RegExp("([\\[\\^\\$\\.|\\?\\*\\+\\(\\)])+","g");return n.replace(e,r=>r.split("").map(t=>"\\"+t).join(""))},l=n=>Object.keys(n).reduce((r,t,s)=>`${r}${s>0?"|":""}${t}`,""),a=(n,e={},r="%")=>{const t=p(r),s=l(e),o=new RegExp(`${t}(${s})${t}`,"g");return n.replace(o,(g,i)=>c.isNil(e[i])?i:e[i])};exports.interpolate=a;
@@ -0,0 +1,14 @@
1
+ import { isNil as c } from "../lang/isNil.js";
2
+ const i = (t) => {
3
+ const e = new RegExp("([\\[\\^\\$\\.|\\?\\*\\+\\(\\)])+", "g");
4
+ return t.replace(
5
+ e,
6
+ (o) => o.split("").map((n) => "\\" + n).join("")
7
+ );
8
+ }, $ = (t) => Object.keys(t).reduce((o, n, p) => `${o}${p > 0 ? "|" : ""}${n}`, ""), d = (t, e = {}, o = "%") => {
9
+ const n = i(o), p = $(e), s = new RegExp(`${n}(${p})${n}`, "g");
10
+ return t.replace(s, (a, r) => c(e[r]) ? r : e[r]);
11
+ };
12
+ export {
13
+ d as interpolate
14
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=(t,e)=>new Function(...Object.keys(e),`return \`${t}\``)(...Object.values(e));exports.interpolateLiteral=n;
@@ -0,0 +1,4 @@
1
+ const r = (t, e) => new Function(...Object.keys(e), `return \`${t}\``)(...Object.values(e));
2
+ export {
3
+ r as interpolateLiteral
4
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=t=>typeof t=="string"||Object.prototype.toString.call(t)==="[object String]";exports.isString=e;
@@ -0,0 +1,4 @@
1
+ const o = (t) => typeof t == "string" || Object.prototype.toString.call(t) === "[object String]";
2
+ export {
3
+ o as isString
4
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@untemps/utils",
3
- "version": "2.5.0",
4
- "description": "",
3
+ "version": "3.0.0",
4
+ "description": "Utils for @untemps packages",
5
5
  "repository": "git@github.com:untemps/utils.git",
6
6
  "keywords": [],
7
7
  "author": "Vincent Le Badezet <v.lebadezet@untemps.net>",
@@ -10,55 +10,39 @@
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
13
+ "type": "module",
13
14
  "files": [
14
15
  "dist"
15
16
  ],
16
17
  "exports": {
17
18
  "./*": {
18
- "import": "./dist/esm/*.js",
19
- "require": "./dist/cjs/*.js"
19
+ "import": "./dist/*.js",
20
+ "require": "./dist/*.cjs"
20
21
  }
21
22
  },
22
23
  "engines": {
23
24
  "node": ">=14.17"
24
25
  },
25
26
  "devDependencies": {
26
- "@babel/cli": "^7.17.6",
27
- "@babel/core": "^7.17.5",
28
- "@babel/plugin-transform-runtime": "^7.17.0",
29
- "@babel/preset-env": "^7.16.11",
30
27
  "@commitlint/cli": "^16.2.3",
31
28
  "@commitlint/config-conventional": "^16.2.1",
32
- "@rollup/plugin-babel": "^5.3.1",
33
- "@rollup/plugin-node-resolve": "^13.1.3",
34
- "@rollup/plugin-strip": "^2.1.0",
35
29
  "@semantic-release/changelog": "^6.0.1",
36
30
  "@semantic-release/git": "^10.0.1",
37
31
  "@semantic-release/github": "^8.0.2",
38
32
  "@testing-library/dom": "^8.11.3",
39
33
  "@testing-library/jest-dom": "^5.16.2",
40
- "babel-jest": "^27.5.1",
41
- "clean-jsdoc-theme": "^4.1.8",
42
34
  "commitlint": "^16.2.3",
43
35
  "cross-env": "^7.0.2",
44
36
  "docdash": "^1.2.0",
45
37
  "fast-check": "^2.22.0",
46
- "foodoc": "^0.0.9",
47
- "glob": "^8.0.3",
38
+ "glob": "^9.3.0",
48
39
  "husky": "^7.0.0",
49
40
  "jest": "^27.5.1",
50
41
  "jsdoc": "^3.6.11",
51
42
  "prettier": "^2.5.1",
52
43
  "rimraf": "^3.0.2",
53
- "rollup": "^2.68.0",
54
- "rollup-plugin-filesize": "^9.1.2",
55
- "rollup-plugin-multi-input": "^1.3.1",
56
- "rollup-plugin-progress": "^1.1.2",
57
- "rollup-plugin-terser": "^7.0.2",
58
- "semantic-release": "^19.0.2"
59
- },
60
- "dependencies": {
61
- "@babel/runtime": "^7.17.8"
44
+ "semantic-release": "^19.0.2",
45
+ "vite": "^4.2.0"
62
46
  },
63
47
  "jest": {
64
48
  "setupFilesAfterEnv": [
@@ -66,7 +50,8 @@
66
50
  ],
67
51
  "testEnvironment": "jsdom",
68
52
  "coverageDirectory": "./coverage/",
69
- "collectCoverage": true
53
+ "collectCoverage": true,
54
+ "transform": {}
70
55
  },
71
56
  "release": {
72
57
  "branches": [
@@ -98,11 +83,9 @@
98
83
  },
99
84
  "scripts": {
100
85
  "docs": "rimraf docs && jsdoc -c jsdoc.json",
101
- "test": "jest -u --watchAll",
102
- "test:ci": "jest -u -b --ci --coverage",
103
- "build": "rimraf dist && yarn build:cjs && yarn build:esm",
104
- "build:cjs": "cross-env NODE_ENV=production BABEL_ENV=cjs rollup -c",
105
- "build:esm": "cross-env NODE_ENV=production BABEL_ENV=esm rollup -c",
86
+ "test": "yarn node --experimental-vm-modules node_modules/jest/bin/jest.js -u --watchAll",
87
+ "test:ci": "yarn node --experimental-vm-modules node_modules/jest/bin/jest.js -u -b --ci --coverage",
88
+ "build": "rimraf dist && vite build",
106
89
  "prettier": "prettier \"*/**/*.js\" --ignore-path ./.prettierignore --write && git add . && git status",
107
90
  "prepare": "husky install"
108
91
  }
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.extractByIndices=function(e,t){var n;return null!==(n=null==e?void 0:e.filter((function(e,n){return null==t?void 0:t.includes(n)})))&&void 0!==n?n:[]};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.standby=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:128;return new Promise((function(t){return setTimeout(t,e)}))};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.createElement=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.tag,n=void 0===t?"div":t,o=e.attributes,d=void 0===o?{}:o,i=e.content,l=void 0===i?null:i,r=e.textContent,u=void 0===r?null:r,a=e.parent,c=void 0===a?null:a,v=e.parentSelector,p=void 0===v?null:v,s=e.boundingClientRect,C=void 0===s?null:s,h=document.createElement(n);for(var g in d)h.setAttribute(g,d[g]);l&&h.appendChild(l),u&&!h.hasChildNodes()&&h.appendChild(document.createTextNode(u));var m=c||document.querySelector(p);return m&&m.appendChild(h),C&&(h.getBoundingClientRect=function(){return C}),h};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.doElementsOverlap=function(t,e){var o=t.getBoundingClientRect(),n=o.left,r=o.right,i=o.top,l=o.bottom,u=e.getBoundingClientRect(),g=u.left,p=u.right,s=u.top;return!(i>u.bottom||r<g||l<s||n>p)};
@@ -1 +0,0 @@
1
- "use strict";function t(t,r){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,r){if(!t)return;if("string"==typeof t)return e(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(t,r)}(t))||r&&t&&"number"==typeof t.length){n&&(t=n);var o=0,a=function(){};return{s:a,n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,l=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return l=t.done,t},e:function(t){u=!0,i=t},f:function(){try{l||null==n.return||n.return()}finally{if(u)throw i}}}}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}Object.defineProperty(exports,"__esModule",{value:!0});exports.getCSSDeclaration=function(e){var r,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e&&(e=e.startsWith(".")?e:".".concat(e),null!==(r=document.styleSheets)&&void 0!==r&&r.length)){var o,a=t(document.styleSheets);try{for(a.s();!(o=a.n()).done;){var i,l=o.value.cssRules,u=t(l);try{for(u.s();!(i=u.n()).done;){var c=i.value,f=c.selectorText,s=c.style;if(f===e&&s)return n?s.cssText:s}}catch(t){u.e(t)}finally{u.f()}}}catch(t){a.e(t)}finally{a.f()}}return null};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.getElement=function(e){return document.querySelector(e)};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.isElement=function(e){return 1===(null==e?void 0:e.nodeType)};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../string/isString.js");exports.modifyElement=function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=r;for(var n in e.isString(r)&&(i=document.querySelector(r)),t){var o,u;if(void 0===t[n]||null===t[n])null===(o=i)||void 0===o||o.removeAttribute(n);else null===(u=i)||void 0===u||u.setAttribute(n,t[n])}return i};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../string/isString.js");exports.removeElement=function(r){var t,i,o=r;return e.isString(r)&&(o=document.querySelector(r)),null===(t=o)||void 0===t||null===(i=t.parentNode)||void 0===i?void 0:i.removeChild(o)};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/toConsumableArray"),r=require("@babel/runtime/helpers/slicedToArray");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=t(e),a=t(r);exports.resolveClassName=function(e){return e.reduce((function(e,r){var t=a.default(r,3),n=t[0],o=t[1],l=t[2];return n&&o?[].concat(u.default(e),[o]):!n&&l?[].concat(u.default(e),[l]):e}),[]).join(" ")};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.isFunction=function(e){return"function"==typeof e};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.isNil=function(e){return null==e};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./normalizeMinMax.js");exports.getRandomInteger=function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-Number.MAX_SAFE_INTEGER,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Number.MAX_SAFE_INTEGER,t=e.normalizeMinMax(r,n),a=t.min,o=t.max;return Math.round(a+Math.random()*(o-a))};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.normalizeMinMax=function(e,t){return{min:Math.min(e,t),max:Math.max(e,t)}};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./isObject.js");exports.deepMerge=function r(t,s){for(var i=0,c=Object.keys(t);i<c.length;i++){var n=c[i];e.isObject(t[n])&&n in s&&Object.assign(t[n],r(t[n],s[n]))}return Object.assign(s||{},t),s};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.isObject=function(e){return Object.getPrototypeOf(e)===Object.prototype};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../number/getRandomInteger.js"),r=require("../number/normalizeMinMax.js"),a=["year","learn","key","cook","crosswalk","script","chief","plan","meat","vague","demonstrator","dictionary","visible","bomber","variation","leader","channel","litigation","royalty","impulse","package","oppose","privilege","begin","operation","herd","hemisphere","incongruous","horror","pipe","start","vertical","worry","reform","unlike","exhibition","disagree","allow","patrol","combine","impress","invisible","cage","log","snow","undertake","division","ethics","damage","responsible"],i=function(e,a){var i=r.normalizeMinMax(Math.abs(e),Math.abs(a)),o=i.min,n=i.max,t=Math.max(o,1);return{min:t,max:Math.max(n,t)}};exports.generateText=function(){for(var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=r.minWords,n=void 0===o?10:o,t=r.maxWords,s=void 0===t?50:t,m=r.dictionary,l=void 0===m?a:m,c="",d=i(n,s),g=d.min,p=d.max,u=e.getRandomInteger(g,p),h=0;h<u;h++){var v=l[Math.floor(Math.random()*l.length)];c+="".concat(h>0?" ":"").concat(v)}return c};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./generateText.js");require("../number/getRandomInteger.js"),require("../number/normalizeMinMax.js");exports.generateTokenizedText=function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.tokens,n=void 0===r?[]:r,o=t.divider,i=void 0===o?"%":o,a=t.minWords,d=void 0===a?10:a,s=t.maxWords,h=void 0===s?50:s,l=t.dictionary,c=void 0===l?void 0:l,g=e.generateText({minWords:Math.max(d,n.length),maxWords:Math.max(h,n.length),dictionary:c}),m=g.split(" "),v=Math.max(Math.floor((m.length-n.length)/n.length),1),x=[],u=0;u<n.length;u++){var M=Math.floor(Math.random()*v)+v*u;m[M]="".concat(i).concat(n[u]).concat(i),x.push(M)}return{indices:x,text:m.join(" ")}};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../lang/isNil.js"),n=function(e){var n=new RegExp("([\\[\\^\\$\\.|\\?\\*\\+\\(\\)])+","g");return e.replace(n,(function(e){return e.split("").map((function(e){return"\\"+e})).join("")}))},t=function(e){return Object.keys(e).reduce((function(e,n,t){return"".concat(e).concat(t>0?"|":"").concat(n)}),"")};exports.interpolate=function(r){var c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"%",i=n(o),u=t(c),a=new RegExp("".concat(i,"(").concat(u,")").concat(i),"g");return r.replace(a,(function(n,t){return e.isNil(c[t])?t:c[t]}))};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/construct"),t=require("@babel/runtime/helpers/toConsumableArray");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=r(e),a=r(t);exports.interpolateLiteral=function(e,t){return u.default(Function,a.default(Object.keys(t)).concat(["return `".concat(e,"`")])).apply(void 0,a.default(Object.values(t)))};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.isString=function(t){return"string"==typeof t||"[object String]"===Object.prototype.toString.call(t)};
@@ -1 +0,0 @@
1
- var n=function(n,l){var r;return null!==(r=null==n?void 0:n.filter((function(n,r){return null==l?void 0:l.includes(r)})))&&void 0!==r?r:[]};export{n as extractByIndices};
@@ -1 +0,0 @@
1
- var e=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:128;return new Promise((function(n){return setTimeout(n,e)}))};export{e as standby};
@@ -1 +0,0 @@
1
- var e=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.tag,n=void 0===t?"div":t,d=e.attributes,o=void 0===d?{}:d,i=e.content,l=void 0===i?null:i,r=e.textContent,u=void 0===r?null:r,a=e.parent,v=void 0===a?null:a,c=e.parentSelector,p=void 0===c?null:c,C=e.boundingClientRect,h=void 0===C?null:C,g=document.createElement(n);for(var m in o)g.setAttribute(m,o[m]);l&&g.appendChild(l),u&&!g.hasChildNodes()&&g.appendChild(document.createTextNode(u));var s=v||document.querySelector(p);return s&&s.appendChild(g),h&&(g.getBoundingClientRect=function(){return h}),g};export{e as createElement};
@@ -1 +0,0 @@
1
- var t=function(t,e){var o=t.getBoundingClientRect(),n=o.left,i=o.right,r=o.top,g=o.bottom,l=e.getBoundingClientRect(),u=l.left,c=l.right,f=l.top;return!(r>l.bottom||i<u||g<f||n>c)};export{t as doElementsOverlap};
@@ -1 +0,0 @@
1
- function t(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,n){if(!t)return;if("string"==typeof t)return r(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);"Object"===e&&t.constructor&&(e=t.constructor.name);if("Map"===e||"Set"===e)return Array.from(t);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return r(t,n)}(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var o=0,a=function(){};return{s:a,n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,l=!0,u=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return l=t.done,t},e:function(t){u=!0,i=t},f:function(){try{l||null==e.return||e.return()}finally{if(u)throw i}}}}function r(t,r){(null==r||r>t.length)&&(r=t.length);for(var n=0,e=new Array(r);n<r;n++)e[n]=t[n];return e}var n=function(r){var n,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(r&&(r=r.startsWith(".")?r:".".concat(r),null!==(n=document.styleSheets)&&void 0!==n&&n.length)){var o,a=t(document.styleSheets);try{for(a.s();!(o=a.n()).done;){var i,l=o.value.cssRules,u=t(l);try{for(u.s();!(i=u.n()).done;){var f=i.value,c=f.selectorText,s=f.style;if(c===r&&s)return e?s.cssText:s}}catch(t){u.e(t)}finally{u.f()}}}catch(t){a.e(t)}finally{a.f()}}return null};export{n as getCSSDeclaration};
@@ -1 +0,0 @@
1
- var e=function(e){return document.querySelector(e)};export{e as getElement};
@@ -1 +0,0 @@
1
- var n=function(n){return 1===(null==n?void 0:n.nodeType)};export{n as isElement};
@@ -1 +0,0 @@
1
- import{isString as r}from"../string/isString.js";var t=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t;for(var o in r(t)&&(i=document.querySelector(t)),e){var n,l;if(void 0===e[o]||null===e[o])null===(n=i)||void 0===n||n.removeAttribute(o);else null===(l=i)||void 0===l||l.setAttribute(o,e[o])}return i};export{t as modifyElement};
@@ -1 +0,0 @@
1
- import{isString as r}from"../string/isString.js";var o=function(o){var e,i,n=o;return r(o)&&(n=document.querySelector(o)),null===(e=n)||void 0===e||null===(i=e.parentNode)||void 0===i?void 0:i.removeChild(n)};export{o as removeElement};
@@ -1 +0,0 @@
1
- import r from"@babel/runtime/helpers/toConsumableArray";import e from"@babel/runtime/helpers/slicedToArray";var o=function(o){return o.reduce((function(o,n){var t=e(n,3),a=t[0],c=t[1],i=t[2];return a&&c?[].concat(r(o),[c]):!a&&i?[].concat(r(o),[i]):o}),[]).join(" ")};export{o as resolveClassName};
@@ -1 +0,0 @@
1
- var n=function(n){return"function"==typeof n};export{n as isFunction};
@@ -1 +0,0 @@
1
- var n=function(n){return null==n};export{n as isNil};
@@ -1 +0,0 @@
1
- import{normalizeMinMax as r}from"./normalizeMinMax.js";var n=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-Number.MAX_SAFE_INTEGER,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Number.MAX_SAFE_INTEGER,a=r(n,o),m=a.min,t=a.max;return Math.round(m+Math.random()*(t-m))};export{n as getRandomInteger};
@@ -1 +0,0 @@
1
- var a=function(a,n){return{min:Math.min(a,n),max:Math.max(a,n)}};export{a as normalizeMinMax};
@@ -1 +0,0 @@
1
- import{isObject as r}from"./isObject.js";var t=function t(e,n){for(var s=0,i=Object.keys(e);s<i.length;s++){var a=i[s];r(e[a])&&a in n&&Object.assign(e[a],t(e[a],n[a]))}return Object.assign(n||{},e),n};export{t as deepMerge};
@@ -1 +0,0 @@
1
- var t=function(t){return Object.getPrototypeOf(t)===Object.prototype};export{t as isObject};
@@ -1 +0,0 @@
1
- import{getRandomInteger as r}from"../number/getRandomInteger.js";import{normalizeMinMax as a}from"../number/normalizeMinMax.js";var e=["year","learn","key","cook","crosswalk","script","chief","plan","meat","vague","demonstrator","dictionary","visible","bomber","variation","leader","channel","litigation","royalty","impulse","package","oppose","privilege","begin","operation","herd","hemisphere","incongruous","horror","pipe","start","vertical","worry","reform","unlike","exhibition","disagree","allow","patrol","combine","impress","invisible","cage","log","snow","undertake","division","ethics","damage","responsible"],i=function(r,e){var i=a(Math.abs(r),Math.abs(e)),o=i.min,n=i.max,t=Math.max(o,1);return{min:t,max:Math.max(n,t)}},o=function(){for(var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=a.minWords,n=void 0===o?10:o,t=a.maxWords,m=void 0===t?50:t,s=a.dictionary,l=void 0===s?e:s,c="",d=i(n,m),p=d.min,h=d.max,v=r(p,h),g=0;g<v;g++){var b=l[Math.floor(Math.random()*l.length)];c+="".concat(g>0?" ":"").concat(b)}return c};export{o as generateText};
@@ -1 +0,0 @@
1
- import{generateText as o}from"./generateText.js";import"../number/getRandomInteger.js";import"../number/normalizeMinMax.js";var t=function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.tokens,r=void 0===n?[]:n,i=t.divider,a=void 0===i?"%":i,e=t.minWords,d=void 0===e?10:e,m=t.maxWords,h=void 0===m?50:m,l=t.dictionary,s=void 0===l?void 0:l,v=o({minWords:Math.max(d,r.length),maxWords:Math.max(h,r.length),dictionary:s}),c=v.split(" "),g=Math.max(Math.floor((c.length-r.length)/r.length),1),x=[],M=0;M<r.length;M++){var p=Math.floor(Math.random()*g)+g*M;c[p]="".concat(a).concat(r[M]).concat(a),x.push(p)}return{indices:x,text:c.join(" ")}};export{t as generateTokenizedText};
@@ -1 +0,0 @@
1
- import{isNil as n}from"../lang/isNil.js";var t=function(n){var t=new RegExp("([\\[\\^\\$\\.|\\?\\*\\+\\(\\)])+","g");return n.replace(t,(function(n){return n.split("").map((function(n){return"\\"+n})).join("")}))},c=function(n){return Object.keys(n).reduce((function(n,t,c){return"".concat(n).concat(c>0?"|":"").concat(t)}),"")},r=function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"%",u=t(o),i=c(e),a=new RegExp("".concat(u,"(").concat(i,")").concat(u),"g");return r.replace(a,(function(t,c){return n(e[c])?c:e[c]}))};export{r as interpolate};
@@ -1 +0,0 @@
1
- import r from"@babel/runtime/helpers/construct";import e from"@babel/runtime/helpers/toConsumableArray";var t=function(t,o){return r(Function,e(Object.keys(o)).concat(["return `".concat(t,"`")])).apply(void 0,e(Object.values(o)))};export{t as interpolateLiteral};
@@ -1 +0,0 @@
1
- var t=function(t){return"string"==typeof t||"[object String]"===Object.prototype.toString.call(t)};export{t as isString};