@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 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
+ ![js-common banner](./banner.png)
4
+
3
5
  [![npm version](https://badge.fury.io/js/%40rtorcato%2Fjs-common.svg)](https://badge.fury.io/js/%40rtorcato%2Fjs-common)
4
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
7
  [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](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
- - โšก **Zero dependencies** - Core library has no external deps
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
- - **Zero dependencies** in core library
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
@@ -1 +1 @@
1
- import"../chunks/chunk-ANN5UYCF.js";function o(t){return t[0]}function u(t){return t.length?t[t.length-1]:void 0}function T(t){return Array.from(new Set(t))}function f(t){return t.flat()}function i(t,n){if(n<1)throw new Error("Chunk size must be at least 1");let e=[];for(let r=0;r<t.length;r+=n)e.push(t.slice(r,r+n));return e}function l(t){return t.filter(Boolean)}function c(t){let n=t.slice();for(let e=n.length-1;e>0;e--){let r=Math.floor(Math.random()*(e+1));[n[e],n[r]]=[n[r],n[e]]}return n}export{i as chunk,l as compact,o as first,f as flatten,u as last,c as shuffle,T as unique};
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};
@@ -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 { category } = await inquirer.prompt([
118
- {
119
- type: 'list',
120
- name: 'category',
121
- message: chalk.cyan('What would you like to do?'),
122
- choices: Object.entries(functionCategories)
123
- .reduce((acc, [key, cat], index) => {
124
- acc.push({ name: cat.name, value: key });
125
- // Add separator after each item except the last one
126
- if (index < Object.entries(functionCategories).length - 1) {
127
- acc.push(new inquirer.Separator(' '));
128
- }
129
- return acc;
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 { functionName } = await inquirer.prompt([
145
- {
146
- type: 'list',
147
- name: 'functionName',
148
- message: chalk.cyan(`Choose a ${selectedCategory.name} function:`),
149
- choices: selectedCategory.functions
150
- .reduce((acc, func, index) => {
151
- acc.push({ name: `${func.name} - ${func.description}`, value: func.name });
152
- // Add separator after each item except the last one
153
- if (index < selectedCategory.functions.length - 1) {
154
- acc.push(new inquirer.Separator(' '));
155
- }
156
- return acc;
157
- }, [])
158
- .concat([
159
- new inquirer.Separator(' '),
160
- { name: chalk.gray('โฌ…๏ธ Back to categories'), value: 'back' },
161
- { name: chalk.red('โŒ Exit'), value: 'exit' },
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 { category } = await inquirer.prompt([
203
- {
204
- type: 'list',
205
- name: 'category',
206
- message: chalk.cyan('Which category of utilities do you need?'),
207
- choices: Object.entries(functionCategories)
208
- .reduce((acc, [key, cat], index) => {
209
- acc.push({ name: cat.name, value: key });
210
- // Add separator after each item except the last one
211
- if (index < Object.entries(functionCategories).length - 1) {
212
- acc.push(new inquirer.Separator(' '));
213
- }
214
- return acc;
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 { functions } = await inquirer.prompt([
228
- {
229
- type: 'checkbox',
230
- name: 'functions',
231
- message: chalk.cyan(`Select ${selectedCategory.name} functions to add:`),
232
- choices: selectedCategory.functions.map((func) => ({
233
- name: `${func.name} - ${func.description}`,
234
- value: func.name,
235
- checked: false,
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;
@@ -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&&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};
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};
@@ -1 +1 @@
1
- import"../chunks/chunk-ANN5UYCF.js";function e(t,r=2){return String(t).padStart(r,"0")}function i(t){return t?t[0]?.toUpperCase()+t.slice(1):""}function u(t){return t.replace(/\w\S*/g,r=>(r[0]?.toUpperCase()??"")+r.slice(1).toLowerCase())}function g(t,r="en-US"){return t.toLocaleString(r)}function s(t,r=0){return`${(t*100).toFixed(r)}%`}function n(t){return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`}function o(t){return`${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}`}function a(t){return`${n(t)} ${o(t)}`}export{i as capitalize,n as formatDate,a as formatDateTime,g as formatNumber,s as formatPercent,o as formatTime,e as padZero,u as toTitleCase};
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};
@@ -1 +1 @@
1
- import"../chunks/chunk-ANN5UYCF.js";function i(n="en"){return typeof process<"u"&&navigator.language?navigator.language.split("-")[0]||n: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 g(n,t,r){let e=r||i();return t[e]?.[n]||t.en?.[n]||n}function u(n,t){return t===1?n:`${n}s`}export{i as detectLanguage,s as formatDateI18n,o as formatNumber,u as pluralize,g as t};
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 o=()=>(console.log("test"),"testPackage"),t=e=>{console.log(`hello ${e??"world"}`)};export{t as helloWorld,o as testPackage};
1
+ import"./chunks/chunk-ANN5UYCF.js";var t=()=>(console.log("test"),"testPackage");export{t as testPackage};
@@ -1 +1 @@
1
- import{a as o,b as t}from"../chunks/chunk-DCFILRIS.js";import"../chunks/chunk-ANN5UYCF.js";var e=(r,m)=>r+m;export{o as add,t as subtract,e as sum};
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};
@@ -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 c(n,r){return Math.random()*(r-n)+n}function f(n){return typeof n=="number"&&Number.isInteger(n)}function a(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}export{p as average,a as between,m as clamp,c as getRandomFloat,o as getRandomInt,i as isFiniteNumber,f as isInteger,x as mod,b as roundTo,u as sum};
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 a(n){return JSON.parse(JSON.stringify(n))}export{a as deepClone,s as deepMerge,r as isPlainObject,c as omit,i as pick};
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};
@@ -1 +1 @@
1
- import"../chunks/chunk-ANN5UYCF.js";function i(r){return r.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())}function s(r){return r.length===0?"":(r[0]?.toUpperCase()??"")+r.slice(1)}function a(r){return r.replace(/[-_\s]+(.)?/g,(e,t)=>t?t.toUpperCase():"").replace(/^(.)/,e=>e.toLowerCase())}function g(r){return r.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").toLowerCase()}function o(r){return r.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[-\s]+/g,"_").toLowerCase()}function p(r,e){return r.length>e?`${r.slice(0,e-1)}\u2026`:r}function c(r,e,t=" "){return r.padStart(e,t)}function u(r,e,t=" "){return r.padEnd(e,t)}var l=(r,e)=>{let t="";for(let n=r;n>0;--n)t+=e[Math.floor(Math.random()*e.length)];return t},f=(r,e,t)=>r.replace(new RegExp(e,"g"),t);function C(r){return r.replace(/<script.*?>.*?<\/script>/gi,"").replace(/on\w+\s*=\s*(['"]).*?\1/gi,"")}export{a as camelCase,s as capitalize,g as kebabCase,u as padEnd,c as padStart,l as randomString,f as replaceString,C as sanitizeString,o as snakeCase,i as titleCase,p as truncate};
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={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};return r.replace(/[&<>"']/g,e=>t[e]??e)}function C(r){let t={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'","&#x27;":"'","&#x2F;":"/","&nbsp;":" "};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};
@@ -1 +1 @@
1
- import"../chunks/chunk-ANN5UYCF.js";import i from"short-uuid";import{NIL as n,parse as e,stringify as U,validate as r,version as s,v4 as a,v7 as g}from"uuid";var o=i(),p=()=>a(),D=()=>g(),c=()=>o.new(),x=t=>o.fromUUID(t),d=t=>o.toUUID(t),l=t=>r(t),v=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=>e(t),h=t=>U(t);export{h as bytesToUUID,d as fromShortUUID,y as getNilUUID,c as getShortUUID,p as getUUID,m as getUUIDVersion,D as getUUIDv7,f as isNilUUID,l as isUUID,v as isUUIDv4,x as toShortUUID,b as uuidToBytes};
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.6.0",
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.25.11",
257
+ "esbuild": "^0.27.4",
258
258
  "husky": "^9.1.7",
259
- "jsdom": "^26.1.0",
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": "^5.9.3",
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": "^12.10.0",
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": "^5.2.0",
279
+ "short-uuid": "^6.0.3",
279
280
  "uuid": "^13.0.0",
280
281
  "zod": "^4.1.12"
281
282
  },