@untemps/utils 4.0.0-beta.3 → 4.0.0-beta.5

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
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../number/normalizeMinMax.cjs`),t=require(`../number/getRandomInteger.cjs`);var n=`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`.split(`.`),r=(t,n)=>{let{min:r,max:i}=e.normalizeMinMax(Math.abs(t),Math.abs(n)),a=Math.max(r,1);return{min:a,max:Math.max(i,a)}},i=({minWords:e=10,maxWords:i=50,dictionary:a=n}={})=>{let o=``,{min:s,max:c}=r(e,i),l=t.getRandomInteger(s,c);for(let e=0;e<l;e++){let t=a[Math.floor(Math.random()*a.length)];o+=`${e>0?` `:``}${t}`}return o};exports.generateText=i;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../number/normalizeMinMax.cjs`),t=require(`../number/getRandomInteger.cjs`);var n=`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`.split(`.`),r=(t,n)=>{let{min:r,max:i}=e.normalizeMinMax(Math.abs(t),Math.abs(n)),a=Math.max(r,1);return{min:a,max:Math.max(i,a)}},i=({minWords:e=10,maxWords:i=50,dictionary:a=n}={})=>{if(!a?.length)throw RangeError(`dictionary must not be empty`);let o=``,{min:s,max:c}=r(e,i),l=t.getRandomInteger(s,c);for(let e=0;e<l;e++){let t=a[Math.floor(Math.random()*a.length)];o+=`${e>0?` `:``}${t}`}return o};exports.generateText=i;
@@ -1 +1 @@
1
- {"version":3,"file":"generateText.d.ts","sourceRoot":"","sources":["../../src/string/generateText.ts"],"names":[],"mappings":"AAAA;;GAEG;AAmEH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;CACrB;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,GAAI,qCAAsD,kBAAuB,KAAG,MAS5G,CAAA"}
1
+ {"version":3,"file":"generateText.d.ts","sourceRoot":"","sources":["../../src/string/generateText.ts"],"names":[],"mappings":"AAAA;;GAEG;AAmEH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;CACrB;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,GAAI,qCAAsD,kBAAuB,KAAG,MAU5G,CAAA"}
@@ -8,6 +8,7 @@ var n = /* @__PURE__ */ "year.learn.key.cook.crosswalk.script.chief.plan.meat.va
8
8
  max: Math.max(i, a)
9
9
  };
10
10
  }, i = ({ minWords: e = 10, maxWords: i = 50, dictionary: a = n } = {}) => {
11
+ if (!a?.length) throw RangeError("dictionary must not be empty");
11
12
  let o = "", { min: s, max: c } = r(e, i), l = t(s, c);
12
13
  for (let e = 0; e < l; e++) {
13
14
  let t = a[Math.floor(Math.random() * a.length)];
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../lang/isNil.cjs`);var t=e=>{let t=RegExp(`([\\[\\^\\$\\.|\\?\\*\\+\\(\\)])+`,`g`);return e.replace(t,e=>e.split(``).map(e=>`\\`+e).join(``))},n=e=>Object.keys(e).reduce((e,t,n)=>`${e}${n>0?`|`:``}${t}`,``),r=(r,i={},a=`%`)=>{let o=t(a),s=n(i),c=RegExp(`${o}(${s})${o}`,`g`);return r.replace(c,(t,n)=>e.isNil(i[n])?n:String(i[n]))};exports.interpolate=r;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../lang/isNil.cjs`);var t=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),n=e=>Object.keys(e).reduce((e,t,n)=>`${e}${n>0?`|`:``}${t}`,``),r=(r,i={},a=`%`)=>{let o=t(a),s=n(i),c=RegExp(`${o}(${s})${o}`,`g`);return r.replace(c,(t,n)=>e.isNil(i[n])?n:String(i[n]))};exports.interpolate=r;
@@ -1 +1 @@
1
- {"version":3,"file":"interpolate.d.ts","sourceRoot":"","sources":["../../src/string/interpolate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAqBH;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,EAAE,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EAAE,gBAAa,KAAG,MAKhG,CAAA"}
1
+ {"version":3,"file":"interpolate.d.ts","sourceRoot":"","sources":["../../src/string/interpolate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAaH;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,EAAE,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EAAE,gBAAa,KAAG,MAKhG,CAAA"}
@@ -1,9 +1,6 @@
1
1
  import { isNil as e } from "../lang/isNil.js";
2
2
  //#region src/string/interpolate.ts
3
- var t = (e) => {
4
- let t = /* @__PURE__ */ RegExp("([\\[\\^\\$\\.|\\?\\*\\+\\(\\)])+", "g");
5
- return e.replace(t, (e) => e.split("").map((e) => "\\" + e).join(""));
6
- }, n = (e) => Object.keys(e).reduce((e, t, n) => `${e}${n > 0 ? "|" : ""}${t}`, ""), r = (r, i = {}, a = "%") => {
3
+ var t = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), n = (e) => Object.keys(e).reduce((e, t, n) => `${e}${n > 0 ? "|" : ""}${t}`, ""), r = (r, i = {}, a = "%") => {
7
4
  let o = t(a), s = n(i), c = RegExp(`${o}(${s})${o}`, "g");
8
5
  return r.replace(c, (t, n) => e(i[n]) ? n : String(i[n]));
9
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@untemps/utils",
3
- "version": "4.0.0-beta.3",
3
+ "version": "4.0.0-beta.5",
4
4
  "description": "Utils for @untemps packages",
5
5
  "repository": "git@github.com:untemps/utils.git",
6
6
  "keywords": [],