@rtorcato/js-common 1.6.0 โ 1.7.1
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.
- package/CHANGELOG.md +15 -0
- package/README.md +4 -2
- package/dist/arrays/index.js +1 -1
- package/dist/cli/index.mjs +57 -76
- package/dist/currency/index.js +1 -1
- package/dist/formatting/index.js +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/math/index.js +1 -1
- package/dist/numbers/index.js +1 -1
- package/dist/{obects โ objects}/index.js +1 -1
- package/dist/strings/index.js +1 -1
- package/dist/uuid/index.js +1 -1
- package/package.json +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [1.7.1](https://github.com/rtorcato/js-common/compare/v1.7.0...v1.7.1) (2026-05-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** migrate to short-uuid v6 and inquirer v13 ([#38](https://github.com/rtorcato/js-common/issues/38)) ([cceae68](https://github.com/rtorcato/js-common/commit/cceae68f08a8e88e0511879b800516046ed27a88))
|
|
7
|
+
* resolve bugs, remove duplicates, and add missing utilities ([43dfc85](https://github.com/rtorcato/js-common/commit/43dfc850e105490279cdca746b53be1dbbfe6355))
|
|
8
|
+
|
|
9
|
+
# [1.7.0](https://github.com/rtorcato/js-common/compare/v1.6.0...v1.7.0) (2026-01-16)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* **strings:** add 12 new string utility functions ([03df6fc](https://github.com/rtorcato/js-common/commit/03df6fc4168c1343be47434a2b4c842be394f61c))
|
|
15
|
+
|
|
1
16
|
# [1.6.0](https://github.com/rtorcato/js-common/compare/v1.5.0...v1.6.0) (2026-01-16)
|
|
2
17
|
|
|
3
18
|
|
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# js-common
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
[](https://badge.fury.io/js/%40rtorcato%2Fjs-common)
|
|
4
6
|
[](https://opensource.org/licenses/MIT)
|
|
5
7
|
[](https://www.typescriptlang.org/)
|
|
@@ -15,7 +17,7 @@ A comprehensive set of common JavaScript and TypeScript utilities for Node.js pr
|
|
|
15
17
|
- ๐ง **TypeScript** - Full type safety and IntelliSense
|
|
16
18
|
- ๐ฅ๏ธ **CLI included** - Use utilities from command line
|
|
17
19
|
- ๐ **Modular** - Import individual modules
|
|
18
|
-
- โก **
|
|
20
|
+
- โก **Utility modules have no dependencies** - CLI features use optional packages isolated to the `cli` subpath
|
|
19
21
|
- ๐งช **Well tested** - Comprehensive test coverage
|
|
20
22
|
|
|
21
23
|
## Installation
|
|
@@ -176,7 +178,7 @@ js-common: 277 bytes (full) / ~50-200 bytes (individual modules)
|
|
|
176
178
|
### ๐ ๏ธ **Modern Development**
|
|
177
179
|
- Built with **TypeScript** for excellent DX
|
|
178
180
|
- **ESM-first** with CommonJS compatibility
|
|
179
|
-
- **
|
|
181
|
+
- **No dependencies in utility modules** โ CLI packages (chalk, commander, etc.) are isolated to the `cli` subpath
|
|
180
182
|
- Comprehensive **test coverage**
|
|
181
183
|
|
|
182
184
|
## Development
|
package/dist/arrays/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunks/chunk-ANN5UYCF.js";function o(
|
|
1
|
+
import"../chunks/chunk-ANN5UYCF.js";function o(n){return n[0]}function T(n){return n.length?n[n.length-1]:void 0}function f(n){return Array.from(new Set(n))}function i(n){return n.flat()}function l(n,e){if(e<1)throw new Error("Chunk size must be at least 1");let t=[];for(let r=0;r<n.length;r+=e)t.push(n.slice(r,r+e));return t}function s(n){return n.filter(Boolean)}function c(n){let e=n.slice();for(let t=e.length-1;t>0;t--){let r=Math.floor(Math.random()*(t+1));[e[t],e[r]]=[e[r],e[t]]}return e}function h(n,e){return n.reduce((t,r)=>{let u=e(r);return t[u]||(t[u]=[]),t[u].push(r),t},{})}export{l as chunk,s as compact,o as first,i as flatten,h as groupBy,T as last,c as shuffle,f as unique};
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { Separator, checkbox, select } from '@inquirer/prompts';
|
|
2
3
|
import chalk from 'chalk';
|
|
3
4
|
import chalkAnimation from 'chalk-animation';
|
|
4
5
|
import { program } from 'commander';
|
|
5
6
|
import figlet from 'figlet';
|
|
6
7
|
import gradient from 'gradient-string';
|
|
7
|
-
import inquirer from 'inquirer';
|
|
8
8
|
import { readFileSync } from 'node:fs';
|
|
9
9
|
import { dirname, resolve } from 'node:path';
|
|
10
10
|
import { fileURLToPath } from 'node:url';
|
|
@@ -114,25 +114,20 @@ program
|
|
|
114
114
|
try {
|
|
115
115
|
// Main interactive loop
|
|
116
116
|
while (true) {
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
.concat([new inquirer.Separator(' '), { name: chalk.red('โ Exit'), value: 'exit' }]),
|
|
132
|
-
pageSize: 17, // Show more items to accommodate separators and exit option
|
|
133
|
-
loop: false, // Don't loop at the end
|
|
134
|
-
},
|
|
135
|
-
]);
|
|
117
|
+
const category = await select({
|
|
118
|
+
message: chalk.cyan('What would you like to do?'),
|
|
119
|
+
choices: Object.entries(functionCategories)
|
|
120
|
+
.reduce((acc, [key, cat], index) => {
|
|
121
|
+
acc.push({ name: cat.name, value: key });
|
|
122
|
+
if (index < Object.entries(functionCategories).length - 1) {
|
|
123
|
+
acc.push(new Separator(' '));
|
|
124
|
+
}
|
|
125
|
+
return acc;
|
|
126
|
+
}, [])
|
|
127
|
+
.concat([new Separator(' '), { name: chalk.red('โ Exit'), value: 'exit' }]),
|
|
128
|
+
pageSize: 17,
|
|
129
|
+
loop: false,
|
|
130
|
+
});
|
|
136
131
|
// Handle exit selection
|
|
137
132
|
if (category === 'exit') {
|
|
138
133
|
console.log(chalk.yellow('\n๐ Goodbye!\n'));
|
|
@@ -141,29 +136,24 @@ program
|
|
|
141
136
|
const selectedCategory = functionCategories[category];
|
|
142
137
|
// Function selection loop
|
|
143
138
|
while (true) {
|
|
144
|
-
const
|
|
145
|
-
{
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
]),
|
|
163
|
-
pageSize: 12, // Show more items to accommodate back/exit options
|
|
164
|
-
loop: false, // Don't loop at the end
|
|
165
|
-
},
|
|
166
|
-
]);
|
|
139
|
+
const functionName = await select({
|
|
140
|
+
message: chalk.cyan(`Choose a ${selectedCategory.name} function:`),
|
|
141
|
+
choices: selectedCategory.functions
|
|
142
|
+
.reduce((acc, func, index) => {
|
|
143
|
+
acc.push({ name: `${func.name} - ${func.description}`, value: func.name });
|
|
144
|
+
if (index < selectedCategory.functions.length - 1) {
|
|
145
|
+
acc.push(new Separator(' '));
|
|
146
|
+
}
|
|
147
|
+
return acc;
|
|
148
|
+
}, [])
|
|
149
|
+
.concat([
|
|
150
|
+
new Separator(' '),
|
|
151
|
+
{ name: chalk.gray('โฌ
๏ธ Back to categories'), value: 'back' },
|
|
152
|
+
{ name: chalk.red('โ Exit'), value: 'exit' },
|
|
153
|
+
]),
|
|
154
|
+
pageSize: 12,
|
|
155
|
+
loop: false,
|
|
156
|
+
});
|
|
167
157
|
// Handle navigation options
|
|
168
158
|
if (functionName === 'exit') {
|
|
169
159
|
console.log(chalk.yellow('\n๐ Goodbye!\n'));
|
|
@@ -199,45 +189,36 @@ program
|
|
|
199
189
|
// Welcome message
|
|
200
190
|
console.log(gradient.pastel('\n๐ง Function Integration Helper\n'));
|
|
201
191
|
try {
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
.
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
.concat([new inquirer.Separator(' '), { name: chalk.red('โ Exit'), value: 'exit' }]),
|
|
217
|
-
pageSize: 17, // Show more items to accommodate separators and exit option
|
|
218
|
-
loop: false, // Don't loop at the end
|
|
219
|
-
},
|
|
220
|
-
]);
|
|
192
|
+
const category = await select({
|
|
193
|
+
message: chalk.cyan('Which category of utilities do you need?'),
|
|
194
|
+
choices: Object.entries(functionCategories)
|
|
195
|
+
.reduce((acc, [key, cat], index) => {
|
|
196
|
+
acc.push({ name: cat.name, value: key });
|
|
197
|
+
if (index < Object.entries(functionCategories).length - 1) {
|
|
198
|
+
acc.push(new Separator(' '));
|
|
199
|
+
}
|
|
200
|
+
return acc;
|
|
201
|
+
}, [])
|
|
202
|
+
.concat([new Separator(' '), { name: chalk.red('โ Exit'), value: 'exit' }]),
|
|
203
|
+
pageSize: 17,
|
|
204
|
+
loop: false,
|
|
205
|
+
});
|
|
221
206
|
// Handle exit selection
|
|
222
207
|
if (category === 'exit') {
|
|
223
208
|
console.log(chalk.yellow('\n๐ Goodbye!\n'));
|
|
224
209
|
return;
|
|
225
210
|
}
|
|
226
211
|
const selectedCategory = functionCategories[category];
|
|
227
|
-
const
|
|
228
|
-
{
|
|
229
|
-
|
|
230
|
-
name:
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
pageSize: 10, // Show more items at once
|
|
238
|
-
loop: false, // Don't loop at the end
|
|
239
|
-
},
|
|
240
|
-
]);
|
|
212
|
+
const functions = await checkbox({
|
|
213
|
+
message: chalk.cyan(`Select ${selectedCategory.name} functions to add:`),
|
|
214
|
+
choices: selectedCategory.functions.map((func) => ({
|
|
215
|
+
name: `${func.name} - ${func.description}`,
|
|
216
|
+
value: func.name,
|
|
217
|
+
checked: false,
|
|
218
|
+
})),
|
|
219
|
+
pageSize: 10,
|
|
220
|
+
loop: false,
|
|
221
|
+
});
|
|
241
222
|
if (functions.length === 0) {
|
|
242
223
|
console.log(chalk.yellow('\n๐ No functions selected. Exiting...\n'));
|
|
243
224
|
return;
|
package/dist/currency/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunks/chunk-ANN5UYCF.js";var o=null;async function a(){if(o)return o;let{default:r}=await import("./currencies.js");return o=r,r}var l=r=>{try{let n=new Intl.NumberFormat("en",{currency:r,style:"currency"}).formatToParts(0).find(e=>e.type==="currency");return n?.value==="\xA4"?void 0:n?.value}catch{return}};function m(r,n="en"){try{return new Intl.DisplayNames([n],{type:"currency"}).of(r.toUpperCase())}catch{return}}function i(r){return{USD:"en-US",EUR:"de-DE",GBP:"en-GB",JPY:"ja-JP",CNY:"zh-CN",CAD:"en-CA",AUD:"en-AU",CHF:"de-CH",NZD:"en-NZ",SGD:"en-SG",HKD:"zh-HK",KRW:"ko-KR",INR:"en-IN",BRL:"pt-BR",MXN:"es-MX",RUB:"ru-RU",ZAR:"en-ZA",SEK:"sv-SE",NOK:"nb-NO",DKK:"da-DK",PLN:"pl-PL",TRY:"tr-TR",THB:"th-TH",MYR:"ms-MY",PHP:"en-PH",IDR:"id-ID",CZK:"cs-CZ",HUF:"hu-HU",ILS:"he-IL",TWD:"zh-TW"}[r.toUpperCase()]??"en"}function p(r,n="USD",e){let t=e??i(n);return new Intl.NumberFormat(t,{style:"currency",currency:n}).format(Number(r))}function d(r,n="USD",e){let t=e??i(n);return new Intl.NumberFormat(t,{style:"currency",currency:n,notation:"compact",compactDisplay:"short"}).format(Number(r))}function s(r){let n=/\d+\.\d{3},\d{2}$/.test(r),e=r;n&&(e=r.replace(/\./g,"").replace(",","."));let t=e.replace(/[^0-9.-]+/g,""),c=Number.parseFloat(t);return Number.isNaN(c)?null:c}function f(r){let n={$:"USD","\u20AC":"EUR","\xA3":"GBP","\xA5":"JPY","\u20B9":"INR","\u20BD":"RUB",R$:"BRL","\u20A9":"KRW","\u0E3F":"THB","\u20AA":"ILS","\u20B1":"PHP","\u20AB":"VND",kr:"SEK",CHF:"CHF",C$:"CAD",A$:"AUD",NZ$:"NZD",HK$:"HKD",S$:"SGD"},e=r.match(/\b([A-Z]{3})\b/);if(e
|
|
1
|
+
import"../chunks/chunk-ANN5UYCF.js";var o=null;async function a(){if(o)return o;let{default:r}=await import("./currencies.js");return o=r,r}var l=r=>{try{let n=new Intl.NumberFormat("en",{currency:r,style:"currency"}).formatToParts(0).find(e=>e.type==="currency");return n?.value==="\xA4"?void 0:n?.value}catch{return}};function m(r,n="en"){try{return new Intl.DisplayNames([n],{type:"currency"}).of(r.toUpperCase())}catch{return}}function i(r){return{USD:"en-US",EUR:"de-DE",GBP:"en-GB",JPY:"ja-JP",CNY:"zh-CN",CAD:"en-CA",AUD:"en-AU",CHF:"de-CH",NZD:"en-NZ",SGD:"en-SG",HKD:"zh-HK",KRW:"ko-KR",INR:"en-IN",BRL:"pt-BR",MXN:"es-MX",RUB:"ru-RU",ZAR:"en-ZA",SEK:"sv-SE",NOK:"nb-NO",DKK:"da-DK",PLN:"pl-PL",TRY:"tr-TR",THB:"th-TH",MYR:"ms-MY",PHP:"en-PH",IDR:"id-ID",CZK:"cs-CZ",HUF:"hu-HU",ILS:"he-IL",TWD:"zh-TW"}[r.toUpperCase()]??"en"}function p(r,n="USD",e){let t=e??i(n);return new Intl.NumberFormat(t,{style:"currency",currency:n}).format(Number(r))}function d(r,n="USD",e){let t=e??i(n);return new Intl.NumberFormat(t,{style:"currency",currency:n,notation:"compact",compactDisplay:"short"}).format(Number(r))}function s(r){let n=/\d+\.\d{3},\d{2}$/.test(r),e=r;n&&(e=r.replace(/\./g,"").replace(",","."));let t=e.replace(/[^0-9.-]+/g,""),c=Number.parseFloat(t);return Number.isNaN(c)?null:c}function f(r){let n={$:"USD","\u20AC":"EUR","\xA3":"GBP","\xA5":"JPY","\u20B9":"INR","\u20BD":"RUB",R$:"BRL","\u20A9":"KRW","\u0E3F":"THB","\u20AA":"ILS","\u20B1":"PHP","\u20AB":"VND",kr:"SEK",CHF:"CHF",C$:"CAD",A$:"AUD",NZ$:"NZD",HK$:"HKD",S$:"SGD"},e=r.match(/\b([A-Z]{3})\b/);if(e?.[1]){let t=s(r);if(t!==null)return{amount:t,currency:e[1]}}for(let[t,c]of Object.entries(n))if(r.includes(t)){let u=s(r);if(u!==null)return{amount:u,currency:c}}return null}function y(r,n,e=2){return Number.parseFloat((r*n).toFixed(e))}async function g(r){return(await a()).includes(r.toUpperCase())}function b(r){try{return new Intl.NumberFormat("en",{style:"currency",currency:r}),!0}catch{return!1}}function C(r,n=2){let e=10**n;return Math.round(r*e)/e}export{y as convertCurrency,p as formatPrice,d as formatPriceCompact,i as getCurrencyLocale,m as getCurrencyName,l as getCurrencySymbol,b as isValidCurrency,g as isValidCurrencyCode,f as parseCurrencyString,s as parsePrice,C as roundTo};
|
package/dist/formatting/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunks/chunk-ANN5UYCF.js";function
|
|
1
|
+
import"../chunks/chunk-ANN5UYCF.js";function n(t,r=2){return String(t).padStart(r,"0")}function i(t,r="en-US"){return t.toLocaleString(r)}function u(t,r=0){return`${(t*100).toFixed(r)}%`}function e(t){return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}function o(t){return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function g(t){return`${e(t)} ${o(t)}`}export{e as formatDate,g as formatDateTime,i as formatNumber,u as formatPercent,o as formatTime,n as padZero};
|
package/dist/i18n/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunks/chunk-ANN5UYCF.js";function i(n="en"){return typeof
|
|
1
|
+
import"../chunks/chunk-ANN5UYCF.js";function i(n="en"){return typeof navigator<"u"&&navigator.language?navigator.language.split("-")[0]||n:typeof process<"u"&&process.env.LANG&&(process.env.LANG??"en").split("_")[0]||n}function o(n,t,r){return new Intl.NumberFormat(t,r).format(n)}function s(n,t,r){return new Intl.DateTimeFormat(t,r).format(n)}function a(n,t,r){let e=r||i();return t[e]?.[n]||t.en?.[n]||n}function g(n,t){return t===1?n:`${n}s`}export{i as detectLanguage,s as formatDateI18n,o as formatNumber,g as pluralize,a as t};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunks/chunk-ANN5UYCF.js";var
|
|
1
|
+
import"./chunks/chunk-ANN5UYCF.js";var t=()=>(console.log("test"),"testPackage");export{t as testPackage};
|
package/dist/math/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as d,b as t,c as i,d as r}from"../chunks/chunk-DCFILRIS.js";import"../chunks/chunk-ANN5UYCF.js";export{d as add,r as divide,i as multiply,t as subtract};
|
package/dist/numbers/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunks/chunk-ANN5UYCF.js";function o(n,r){return Math.floor(Math.random()*(r-n+1))+n}function m(n,r,e){return Math.max(r,Math.min(e,n))}function b(n,r=2){let e=10**r;return Math.round(n*e)/e}function i(n){return typeof n=="number"&&Number.isFinite(n)}function
|
|
1
|
+
import"../chunks/chunk-ANN5UYCF.js";function o(n,r){return Math.floor(Math.random()*(r-n+1))+n}function m(n,r,e){return Math.max(r,Math.min(e,n))}function b(n,r=2){let e=10**r;return Math.round(n*e)/e}function i(n){return typeof n=="number"&&Number.isFinite(n)}function a(n,r){return Math.random()*(r-n)+n}function c(n){return typeof n=="number"&&Number.isInteger(n)}function f(n,r,e,t=!0){return t?n>=r&&n<=e:n>r&&n<e}function u(n){return n.reduce((r,e)=>r+e,0)}function p(n){return n.length===0?0:u(n)/n.length}function x(n,r){return(n%r+r)%r}function h(n){return Math.min(...n)}function d(n){return Math.max(...n)}export{p as average,f as between,m as clamp,a as getRandomFloat,o as getRandomInt,i as isFiniteNumber,c as isInteger,d as max,h as min,x as mod,b as roundTo,u as sum};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunks/chunk-ANN5UYCF.js";function r(n){return Object.prototype.toString.call(n)==="[object Object]"}function s(n,o){let t={...n};for(let e in o)r(o[e])&&r(t[e])?t[e]=s(t[e],o[e]):t[e]=o[e];return t}function c(n,o){let t={...n};for(let e of o)delete t[e];return t}function i(n,o){let t={};for(let e of o)e in n&&(t[e]=n[e]);return t}function
|
|
1
|
+
import"../chunks/chunk-ANN5UYCF.js";function r(n){return Object.prototype.toString.call(n)==="[object Object]"}function s(n,o){let t={...n};for(let e in o)r(o[e])&&r(t[e])?t[e]=s(t[e],o[e]):t[e]=o[e];return t}function c(n,o){let t={...n};for(let e of o)delete t[e];return t}function i(n,o){let t={};for(let e of o)e in n&&(t[e]=n[e]);return t}function T(n){return structuredClone(n)}export{T as deepClone,s as deepMerge,r as isPlainObject,c as omit,i as pick};
|
package/dist/strings/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunks/chunk-ANN5UYCF.js";function
|
|
1
|
+
import"../chunks/chunk-ANN5UYCF.js";function s(r){return r.replace(/\w\S*/g,t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase())}function o(r){return r.length===0?"":(r[0]?.toUpperCase()??"")+r.slice(1)}function g(r){return r.replace(/[-_\s]+(.)?/g,(t,e)=>e?e.toUpperCase():"").replace(/^(.)/,t=>t.toLowerCase())}function a(r){return r.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").toLowerCase()}function p(r){return r.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[-\s]+/g,"_").toLowerCase()}function c(r,t){return r.length>t?`${r.slice(0,t-1)}\u2026`:r}function u(r,t,e=" "){return r.padStart(t,e)}function l(r,t,e=" "){return r.padEnd(t,e)}var f=(r,t)=>{let e="";for(let n=r;n>0;--n)e+=t[Math.floor(Math.random()*t.length)];return e},x=(r,t,e)=>r.replace(new RegExp(t,"g"),e);function m(r){return r.replace(/<script.*?>.*?<\/script>/gi,"").replace(/on\w+\s*=\s*(['"]).*?\1/gi,"")}function b(r){return[...r].reverse().join("")}function $(r){return r.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim().replace(/[^a-z0-9\s-]/g,"").replace(/[\s_]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function h(r){return r.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[-_]+/g," ").trim().split(/\s+/).filter(Boolean)}function w(r){let t=r.trim();return t===""?0:t.split(/\s+/).length}function d(r){let t={"&":"&","<":"<",">":">",'"':""","'":"'"};return r.replace(/[&<>"']/g,e=>t[e]??e)}function C(r){let t={"&":"&","<":"<",">":">",""":'"',"'":"'","'":"'","/":"/"," ":" "};return r.replace(/&(?:amp|lt|gt|quot|#39|#x27|#x2F|nbsp);/g,e=>t[e]??e)}function z(r){return r.replace(/<[^>]*>/g,"")}function S(r,t,e){return t===1?r:e??`${r}s`}function _(r){let t=Math.abs(r),e=t%100,n=t%10;if(e>=11&&e<=13)return`${r}th`;switch(n){case 1:return`${r}st`;case 2:return`${r}nd`;case 3:return`${r}rd`;default:return`${r}th`}}function k(r){return r.trim().length===0}function A(r,t,e,n="*"){if(t<0&&(t=0),e>r.length&&(e=r.length),t>=e)return r;let i=n.repeat(e-t);return r.slice(0,t)+i+r.slice(e)}function E(r,t){return r.replace(/\$\{(\w+)\}/g,(e,n)=>Object.hasOwn(t,n)?String(t[n]):e)}export{g as camelCase,o as capitalize,d as escapeHtml,k as isBlank,a as kebabCase,A as mask,_ as ordinalize,l as padEnd,u as padStart,S as pluralize,f as randomString,x as replaceString,b as reverse,m as sanitizeString,$ as slugify,p as snakeCase,z as stripHtml,E as template,s as titleCase,c as truncate,C as unescapeHtml,w as wordCount,h as words};
|
package/dist/uuid/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunks/chunk-ANN5UYCF.js";import
|
|
1
|
+
import"../chunks/chunk-ANN5UYCF.js";import{createTranslator as e}from"short-uuid";import{NIL as n,parse as i,stringify as U,validate as r,version as s,v4 as a,v7 as g}from"uuid";var o=e(),p=()=>a(),D=()=>g(),c=()=>o.generate(),x=t=>o.fromUUID(t),l=t=>o.toUUID(t),v=t=>r(t),d=t=>r(t)&&s(t)===4,f=t=>t===n,m=t=>{if(!r(t))throw new Error("Invalid UUID");return s(t)},y=()=>n,b=t=>i(t),h=t=>U(t);export{h as bytesToUUID,l as fromShortUUID,y as getNilUUID,c as getShortUUID,p as getUUID,m as getUUIDVersion,D as getUUIDv7,f as isNilUUID,v as isUUID,d as isUUIDv4,x as toShortUUID,b as uuidToBytes};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rtorcato/js-common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "JavaScript and TypeScript common code",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"scripts": {
|
|
29
29
|
"build-dev": "rimraf ./dist && cross-env NODE_ENV=development node build.mjs && tsc --emitDeclarationOnly --project tsconfig.build.json && npm run build-cli",
|
|
30
30
|
"build-prod": "rimraf ./dist && cross-env NODE_ENV=production node build.mjs && tsc --emitDeclarationOnly --project tsconfig.build.json && npm run build-cli",
|
|
31
|
-
"build-cli": "tsc src/cli/cli.ts --outDir dist/cli --target ES2022 --module ES2022 --moduleResolution bundler --allowImportingTsExtensions false --esModuleInterop --skipLibCheck && mv dist/cli/cli.js dist/cli/temp.mjs && echo '#!/usr/bin/env node' > dist/cli/index.mjs && cat dist/cli/temp.mjs >> dist/cli/index.mjs && rm dist/cli/temp.mjs && chmod +x dist/cli/index.mjs",
|
|
31
|
+
"build-cli": "tsc src/cli/cli.ts --ignoreConfig --types node --outDir dist/cli --target ES2022 --module ES2022 --moduleResolution bundler --allowImportingTsExtensions false --esModuleInterop --skipLibCheck && mv dist/cli/cli.js dist/cli/temp.mjs && echo '#!/usr/bin/env node' > dist/cli/index.mjs && cat dist/cli/temp.mjs >> dist/cli/index.mjs && rm dist/cli/temp.mjs && chmod +x dist/cli/index.mjs",
|
|
32
32
|
"prepublishOnly": "npm run build-prod",
|
|
33
33
|
"==================== Common ====================": "",
|
|
34
34
|
"lint": "pnpm exec biome lint .",
|
|
@@ -254,16 +254,17 @@
|
|
|
254
254
|
"@types/node": "^24.9.1",
|
|
255
255
|
"@vitest/coverage-istanbul": "^4.0.17",
|
|
256
256
|
"cross-env": "^10.1.0",
|
|
257
|
-
"esbuild": "^0.
|
|
257
|
+
"esbuild": "^0.27.4",
|
|
258
258
|
"husky": "^9.1.7",
|
|
259
|
-
"jsdom": "^
|
|
259
|
+
"jsdom": "^29.0.1",
|
|
260
260
|
"lint-staged": "^16.2.6",
|
|
261
261
|
"rimraf": "^6.0.1",
|
|
262
262
|
"semantic-release": "^25.0.1",
|
|
263
|
-
"typescript": "^
|
|
263
|
+
"typescript": "^6.0.2",
|
|
264
264
|
"vitest": "^4.0.17"
|
|
265
265
|
},
|
|
266
266
|
"dependencies": {
|
|
267
|
+
"@inquirer/prompts": "^8.5.0",
|
|
267
268
|
"chalk": "^5.6.2",
|
|
268
269
|
"chalk-animation": "^2.0.3",
|
|
269
270
|
"commander": "^14.0.1",
|
|
@@ -271,11 +272,11 @@
|
|
|
271
272
|
"date-fns-tz": "^3.2.0",
|
|
272
273
|
"figlet": "^1.9.3",
|
|
273
274
|
"gradient-string": "^3.0.0",
|
|
274
|
-
"inquirer": "^
|
|
275
|
+
"inquirer": "^13.3.2",
|
|
275
276
|
"luxon": "^3.7.2",
|
|
276
277
|
"nanospinner": "^1.2.2",
|
|
277
278
|
"pino": "^10.1.0",
|
|
278
|
-
"short-uuid": "^
|
|
279
|
+
"short-uuid": "^6.0.3",
|
|
279
280
|
"uuid": "^13.0.0",
|
|
280
281
|
"zod": "^4.1.12"
|
|
281
282
|
},
|