@stacksjs/strings 0.72.103 → 0.73.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.
package/dist/helpers.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare function toString(v: any): string;
1
+ export declare function toString(v: unknown): string;
2
2
  /**
3
3
  * Mask a portion of a string with a repeated character, Laravel-style
4
4
  * (stacksjs/stacks#314).
package/dist/utils.d.ts CHANGED
@@ -41,7 +41,7 @@ export declare function ensureSuffix(suffix: string, str: string): string;
41
41
  * ) // Hello Buddy! My name is Chris.
42
42
  * ```
43
43
  */
44
- export declare function template(str: string, ...args: any[]): string;
44
+ export declare function template(str: string, ...args: unknown[]): string;
45
45
  export declare function truncate(str: string, length: number, end?: string): string;
46
46
  /**
47
47
  * Generate a random string.
package/dist/utils.js CHANGED
@@ -1 +1 @@
1
- import{slugify}from"./slug";export const urlAlphabet="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";export function slash(str){return str.replace(/\\/g,"/")}export function ensurePrefix(prefix,str){if(!str.startsWith(prefix))return prefix+str;return str}export function ensureSuffix(suffix,str){return str.endsWith(suffix)?str:str+suffix}export function template(str,...args){return str.replace(/\{(\d+)\}/g,(match,key)=>{const index=Number(key);return Number.isNaN(index)||args[index]===void 0?match:args[index]})}export function truncate(str,length,end="..."){if(str.length<=length)return str;return str.slice(0,length-end.length)+end}export function random(size=16,dict=urlAlphabet){const len=dict.length,g=globalThis;if(!g.crypto?.getRandomValues)throw Error("[strings.random] crypto.getRandomValues is not available; cannot generate secure random string.");const bytes=new Uint8Array(size);g.crypto.getRandomValues(bytes);let id="";for(let i=0;i<size;i++)id+=dict[(bytes[i]??0)%len];return id}export function slug(str,options){if(options)return slugify(str,options);return slugify(str,{lower:!0,strict:!0})}export*from"./detect-indent";export*from"./detect-newline";
1
+ import{slugify}from"./slug";export const urlAlphabet="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";export function slash(str){return str.replace(/\\/g,"/")}export function ensurePrefix(prefix,str){if(!str.startsWith(prefix))return prefix+str;return str}export function ensureSuffix(suffix,str){return str.endsWith(suffix)?str:str+suffix}export function template(str,...args){return str.replace(/\{(\d+)\}/g,(match,key)=>{const index=Number(key);return Number.isNaN(index)||args[index]===void 0?match:String(args[index])})}export function truncate(str,length,end="..."){if(str.length<=length)return str;return str.slice(0,length-end.length)+end}export function random(size=16,dict=urlAlphabet){const len=dict.length,g=globalThis;if(!g.crypto?.getRandomValues)throw Error("[strings.random] crypto.getRandomValues is not available; cannot generate secure random string.");const bytes=new Uint8Array(size);g.crypto.getRandomValues(bytes);let id="";for(let i=0;i<size;i++)id+=dict[(bytes[i]??0)%len];return id}export function slug(str,options){if(options)return slugify(str,options);return slugify(str,{lower:!0,strict:!0})}export*from"./detect-indent";export*from"./detect-newline";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/strings",
3
3
  "type": "module",
4
- "version": "0.72.103",
4
+ "version": "0.73.0",
5
5
  "description": "The Stacks string utilities.",
6
6
  "author": "Chris Breuer",
7
7
  "contributors": [
@@ -69,9 +69,9 @@
69
69
  "prepublishOnly": "bun run build"
70
70
  },
71
71
  "devDependencies": {
72
- "@stacksjs/alias": "0.72.103",
72
+ "@stacksjs/alias": "0.73.0",
73
73
  "better-dx": "^0.2.24",
74
- "@stacksjs/types": "0.72.103"
74
+ "@stacksjs/types": "0.73.0"
75
75
  },
76
76
  "sideEffects": false
77
77
  }