@pixpilot/string 1.0.2 → 2.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.
- package/README.md +36 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -1
- package/dist/manipulation.d.ts +155 -0
- package/dist/type-guards.d.ts +14 -0
- package/dist/validation.d.ts +56 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -11,15 +11,28 @@ pnpm add @pixpilot/string
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { toCamelCase, toKebabCase } from '@pixpilot/string';
|
|
14
|
+
import { isString, toCamelCase, toKebabCase, truncate } from '@pixpilot/string';
|
|
15
15
|
|
|
16
|
-
//
|
|
16
|
+
// Case conversion
|
|
17
17
|
const camel = toCamelCase('hello world'); // 'helloWorld'
|
|
18
18
|
const kebab = toKebabCase('hello world'); // 'hello-world'
|
|
19
|
+
|
|
20
|
+
// String manipulation
|
|
21
|
+
const maxLength = 10;
|
|
22
|
+
const short = truncate('This is a long string', maxLength); // 'This is a ...'
|
|
23
|
+
|
|
24
|
+
// Type guards and validation
|
|
25
|
+
if (isString(value)) {
|
|
26
|
+
// value is typed as string
|
|
27
|
+
}
|
|
19
28
|
```
|
|
20
29
|
|
|
21
30
|
## API
|
|
22
31
|
|
|
32
|
+
### Type Guards
|
|
33
|
+
|
|
34
|
+
- `isString(value: unknown): value is string` - Type guard to check if a value is a string
|
|
35
|
+
|
|
23
36
|
### Case Conversion Functions
|
|
24
37
|
|
|
25
38
|
- `toCamelCase(str: string): string` - Convert a string to camel case (`fooBar`)
|
|
@@ -35,6 +48,27 @@ const kebab = toKebabCase('hello world'); // 'hello-world'
|
|
|
35
48
|
- `toSnakeCase(str: string): string` - Convert a string to snake case (`snake_case`)
|
|
36
49
|
- `toTrainCase(str: string): string` - Convert a string to train case (`Train-Case`)
|
|
37
50
|
|
|
51
|
+
### Validation Functions
|
|
52
|
+
|
|
53
|
+
- `isEmpty(str: string, trimWhitespace?: boolean): boolean` - Check if a string is empty
|
|
54
|
+
- `isAlphanumeric(str: string): boolean` - Check if a string contains only alphanumeric characters
|
|
55
|
+
- `isEmail(str: string): boolean` - Check if a string is a valid email address
|
|
56
|
+
- `isUrl(str: string): boolean` - Check if a string is a valid URL
|
|
57
|
+
|
|
58
|
+
### Manipulation Functions
|
|
59
|
+
|
|
60
|
+
- `truncate(str: string, maxLength: number, ellipsis?: string): string` - Truncate a string
|
|
61
|
+
- `capitalize(str: string): string` - Capitalize the first letter
|
|
62
|
+
- `capitalizeFirst(str: string): string` - Capitalize first letter and lowercase rest
|
|
63
|
+
- `reverse(str: string): string` - Reverse a string
|
|
64
|
+
- `removeWhitespace(str: string): string` - Remove all whitespace
|
|
65
|
+
- `normalizeSpaces(str: string): string` - Replace multiple spaces with single space
|
|
66
|
+
- `padStart(str: string, targetLength: number, padString?: string): string` - Pad from the start
|
|
67
|
+
- `padEnd(str: string, targetLength: number, padString?: string): string` - Pad from the end
|
|
68
|
+
- `repeat(str: string, count: number): string` - Repeat a string
|
|
69
|
+
- `countOccurrences(str: string, searchValue: string, caseSensitive?: boolean): number` - Count occurrences
|
|
70
|
+
- `words(str: string): string[]` - Extract words from a string
|
|
71
|
+
|
|
38
72
|
## Contributing
|
|
39
73
|
|
|
40
74
|
We welcome contributions! Please see the [main contributing guide](../../CONTRIBUTING.md) for details.
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const t=/([\p{Ll}\d])(\p{Lu})/gu,e=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,r=/(\d)\p{Ll}|(\p{L})\d/u,n=/[^\p{L}\d]+/giu,o="$1\0$2";function c(r){let c=r.trim();c=c.replace(t,o).replace(e,o),c=c.replace(n,"\0");let i=0,s=c.length;for(;"\0"===c.charAt(i);)i++;if(i===s)return[];for(;"\0"===c.charAt(s-1);)s--;return c.slice(i,s).split(/\0/g)}function i(t){const e=c(t);for(let t=0;t<e.length;t++){const n=e[t],o=r.exec(n);if(o){const r=o.index+(o[1]??o[2]).length;e.splice(t,1,n.slice(0,r),n.slice(r))}}return e}function s(t,e){const[r,n,o]=x(t,e);return r+n.map(a(e?.locale)).join(e?.delimiter??" ")+o}function u(t,e){const[r,n,o]=x(t,e),c=a(e?.locale),i=l(e?.locale);return r+n.map(p(c,i)).join(e?.delimiter??" ")+o}function a(t){return!1===t?t=>t.toLowerCase():e=>e.toLocaleLowerCase(t)}function l(t){return!1===t?t=>t.toUpperCase():e=>e.toLocaleUpperCase(t)}function p(t,e){return r=>`${e(r[0])}${t(r.slice(1))}`}function f(t,e){return(r,n)=>{const o=r[0];return(n>0&&o>="0"&&o<="9"?"_"+o:e(o))+t(r.slice(1))}}function x(t,e={}){const r=e.split??(e.separateNumbers?i:c),n=e.prefixCharacters??"",o=e.suffixCharacters??"";let s=0,u=t.length;for(;s<t.length;){const e=t.charAt(s);if(!n.includes(e))break;s++}for(;u>s;){const e=u-1,r=t.charAt(e);if(!o.includes(r))break;u=e}return[t.slice(0,s),r(t.slice(s,u)),t.slice(u)]}exports.capitalize=function(t){return 0===t.length?t:t.charAt(0).toUpperCase()+t.slice(1)},exports.capitalizeFirst=function(t){return 0===t.length?t:t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()},exports.countOccurrences=function(t,e,r=!0){if(0===e.length)return 0;const n=r?t:t.toLowerCase(),o=r?e:e.toLowerCase();let c=0,i=0;for(;;){const t=n.indexOf(o,i);if(-1===t)break;c++,i=t+1}return c},exports.isAlphanumeric=function(t){return/^[\da-z]+$/iu.test(t)},exports.isEmail=function(t){return/^[^\s@]+@[^\s@][^\s.@]*\.[^\s@]+$/u.test(t)},exports.isEmpty=function(t,e=!0){return e?0===t.trim().length:0===t.length},exports.isString=function(t){return"string"==typeof t},exports.isUrl=function(t){try{const e=new URL(t);return Boolean(e)}catch{return!1}},exports.normalizeSpaces=function(t){return t.replace(/\s+/gu," ").trim()},exports.padEnd=function(t,e,r=" "){return t.padEnd(e,r)},exports.padStart=function(t,e,r=" "){return t.padStart(e,r)},exports.removeWhitespace=function(t){return t.replace(/\s+/gu,"")},exports.repeat=function(t,e){return t.repeat(e)},exports.reverse=function(t){return t.split("").reverse().join("")},exports.toCamelCase=function(t){return function(t,e){const[r,n,o]=x(t,e),c=a(e?.locale),i=l(e?.locale),s=f(c,i);return r+n.map((t,e)=>0===e?c(t):s(t,e)).join("")+o}(t)},exports.toCapitalCase=function(t){return u(t)},exports.toConstantCase=function(t){return function(t,e){const[r,n,o]=x(t,e);return r+n.map(l(e?.locale)).join("_")+o}(t)},exports.toDotCase=function(t){return s(t,{delimiter:".",...e});var e},exports.toKebabCase=function(t){return s(t,{delimiter:"-",...e});var e},exports.toNoCase=function(t){return s(t)},exports.toPascalCase=function(t){return function(t,e){const[r,n,o]=x(t,e),c=f(a(e?.locale),l(e?.locale));return r+n.map(c).join("")+o}(t)},exports.toPascalSnakeCase=function(t){return u(t,{delimiter:"_",...e});var e},exports.toPathCase=function(t){return s(t,{delimiter:"/",...e});var e},exports.toSentenceCase=function(t){return function(t,e){const[r,n,o]=x(t,e),c=a(e?.locale),i=l(e?.locale),s=p(c,i);return r+n.map((t,e)=>0===e?s(t):c(t)).join(" ")+o}(t)},exports.toSnakeCase=function(t){return s(t,{delimiter:"_",...e});var e},exports.toTrainCase=function(t){return u(t,{delimiter:"-",...e});var e},exports.truncate=function(t,e,r="..."){return t.length<=e?t:t.slice(0,e)+r},exports.words=function(t){return t.match(/[A-Z]?[a-z]+|[A-Z]+(?![a-z])|\d+/gu)||[]};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const n=/([\p{Ll}\d])(\p{Lu})/gu,
|
|
1
|
+
const n=/([\p{Ll}\d])(\p{Lu})/gu,t=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,e=/(\d)\p{Ll}|(\p{L})\d/u,r=/[^\p{L}\d]+/giu,u="$1\0$2";function c(e){let c=e.trim();c=c.replace(n,u).replace(t,u),c=c.replace(r,"\0");let o=0,i=c.length;for(;"\0"===c.charAt(o);)o++;if(o===i)return[];for(;"\0"===c.charAt(i-1);)i--;return c.slice(o,i).split(/\0/g)}function o(n){const t=c(n);for(let n=0;n<t.length;n++){const r=t[n],u=e.exec(r);if(u){const e=u.index+(u[1]??u[2]).length;t.splice(n,1,r.slice(0,e),r.slice(e))}}return t}function i(n,t){const[e,r,u]=d(n,t);return e+r.map(a(t?.locale)).join(t?.delimiter??" ")+u}function l(n,t){const[e,r,u]=d(n,t),c=a(t?.locale),o=f(t?.locale);return e+r.map(s(c,o)).join(t?.delimiter??" ")+u}function a(n){return!1===n?n=>n.toLowerCase():t=>t.toLocaleLowerCase(n)}function f(n){return!1===n?n=>n.toUpperCase():t=>t.toLocaleUpperCase(n)}function s(n,t){return e=>`${t(e[0])}${n(e.slice(1))}`}function p(n,t){return(e,r)=>{const u=e[0];return(r>0&&u>="0"&&u<="9"?"_"+u:t(u))+n(e.slice(1))}}function d(n,t={}){const e=t.split??(t.separateNumbers?o:c),r=t.prefixCharacters??"",u=t.suffixCharacters??"";let i=0,l=n.length;for(;i<n.length;){const t=n.charAt(i);if(!r.includes(t))break;i++}for(;l>i;){const t=l-1,e=n.charAt(t);if(!u.includes(e))break;l=t}return[n.slice(0,i),e(n.slice(i,l)),n.slice(l)]}function h(n){return function(n,t){const[e,r,u]=d(n,t),c=a(t?.locale),o=f(t?.locale),i=p(c,o);return e+r.map((n,t)=>0===t?c(n):i(n,t)).join("")+u}(n)}function g(n){return l(n)}function m(n){return function(n,t){const[e,r,u]=d(n,t);return e+r.map(f(t?.locale)).join("_")+u}(n)}function L(n){return i(n,{delimiter:".",...t});var t}function C(n){return i(n,{delimiter:"-",...t});var t}function A(n){return i(n)}function j(n){return function(n,t){const[e,r,u]=d(n,t),c=p(a(t?.locale),f(t?.locale));return e+r.map(c).join("")+u}(n)}function v(n){return l(n,{delimiter:"_",...t});var t}function w(n){return i(n,{delimiter:"/",...t});var t}function x(n){return function(n,t){const[e,r,u]=d(n,t),c=a(t?.locale),o=f(t?.locale),i=s(c,o);return e+r.map((n,t)=>0===t?i(n):c(n)).join(" ")+u}(n)}function $(n){return i(n,{delimiter:"_",...t});var t}function U(n){return l(n,{delimiter:"-",...t});var t}function b(n,t,e="..."){return n.length<=t?n:n.slice(0,t)+e}function _(n){return 0===n.length?n:n.charAt(0).toUpperCase()+n.slice(1)}function k(n){return 0===n.length?n:n.charAt(0).toUpperCase()+n.slice(1).toLowerCase()}function z(n){return n.split("").reverse().join("")}function y(n){return n.replace(/\s+/gu,"")}function Z(n){return n.replace(/\s+/gu," ").trim()}function B(n,t,e=" "){return n.padStart(t,e)}function E(n,t,e=" "){return n.padEnd(t,e)}function N(n,t){return n.repeat(t)}function O(n,t,e=!0){if(0===t.length)return 0;const r=e?n:n.toLowerCase(),u=e?t:t.toLowerCase();let c=0,o=0;for(;;){const n=r.indexOf(u,o);if(-1===n)break;c++,o=n+1}return c}function R(n){return n.match(/[A-Z]?[a-z]+|[A-Z]+(?![a-z])|\d+/gu)||[]}function S(n){return"string"==typeof n}function q(n,t=!0){return t?0===n.trim().length:0===n.length}function D(n){return/^[\da-z]+$/iu.test(n)}function F(n){return/^[^\s@]+@[^\s@][^\s.@]*\.[^\s@]+$/u.test(n)}function G(n){try{const t=new URL(n);return Boolean(t)}catch{return!1}}export{_ as capitalize,k as capitalizeFirst,O as countOccurrences,D as isAlphanumeric,F as isEmail,q as isEmpty,S as isString,G as isUrl,Z as normalizeSpaces,E as padEnd,B as padStart,y as removeWhitespace,N as repeat,z as reverse,h as toCamelCase,g as toCapitalCase,m as toConstantCase,L as toDotCase,C as toKebabCase,A as toNoCase,j as toPascalCase,v as toPascalSnakeCase,w as toPathCase,x as toSentenceCase,$ as toSnakeCase,U as toTrainCase,b as truncate,R as words};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Truncate a string to a specified length, adding an ellipsis if truncated.
|
|
3
|
+
*
|
|
4
|
+
* @param str - The string to truncate
|
|
5
|
+
* @param maxLength - The maximum length of the string
|
|
6
|
+
* @param ellipsis - The ellipsis to append (default: '...')
|
|
7
|
+
* @returns The truncated string
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* truncate('Hello World', 5); // 'Hello...'
|
|
12
|
+
* truncate('Hello', 10); // 'Hello'
|
|
13
|
+
* truncate('Hello World', 5, '…'); // 'Hello…'
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function truncate(str: string, maxLength: number, ellipsis?: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Capitalize the first letter of a string.
|
|
19
|
+
*
|
|
20
|
+
* @param str - The string to capitalize
|
|
21
|
+
* @returns The capitalized string
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* capitalize('hello'); // 'Hello'
|
|
26
|
+
* capitalize('WORLD'); // 'WORLD'
|
|
27
|
+
* capitalize(''); // ''
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function capitalize(str: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Capitalize the first letter of a string and lowercase the rest.
|
|
33
|
+
*
|
|
34
|
+
* @param str - The string to capitalize
|
|
35
|
+
* @returns The capitalized string
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* capitalizeFirst('hello'); // 'Hello'
|
|
40
|
+
* capitalizeFirst('WORLD'); // 'World'
|
|
41
|
+
* capitalizeFirst('hELLO wORLD'); // 'Hello world'
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function capitalizeFirst(str: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Reverse a string.
|
|
47
|
+
*
|
|
48
|
+
* @param str - The string to reverse
|
|
49
|
+
* @returns The reversed string
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* reverse('hello'); // 'olleh'
|
|
54
|
+
* reverse('abc123'); // '321cba'
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function reverse(str: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Remove all whitespace from a string.
|
|
60
|
+
*
|
|
61
|
+
* @param str - The string to process
|
|
62
|
+
* @returns The string without whitespace
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* removeWhitespace('hello world'); // 'helloworld'
|
|
67
|
+
* removeWhitespace(' a b c '); // 'abc'
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function removeWhitespace(str: string): string;
|
|
71
|
+
/**
|
|
72
|
+
* Replace multiple consecutive spaces with a single space.
|
|
73
|
+
*
|
|
74
|
+
* @param str - The string to process
|
|
75
|
+
* @returns The string with normalized spaces
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* normalizeSpaces('hello world'); // 'hello world'
|
|
80
|
+
* normalizeSpaces('a b c'); // 'a b c'
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare function normalizeSpaces(str: string): string;
|
|
84
|
+
/**
|
|
85
|
+
* Pad a string to a specified length from the start.
|
|
86
|
+
*
|
|
87
|
+
* @param str - The string to pad
|
|
88
|
+
* @param targetLength - The target length
|
|
89
|
+
* @param padString - The string to pad with (default: ' ')
|
|
90
|
+
* @returns The padded string
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* padStart('5', 3, '0'); // '005'
|
|
95
|
+
* padStart('hello', 10); // ' hello'
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare function padStart(str: string, targetLength: number, padString?: string): string;
|
|
99
|
+
/**
|
|
100
|
+
* Pad a string to a specified length from the end.
|
|
101
|
+
*
|
|
102
|
+
* @param str - The string to pad
|
|
103
|
+
* @param targetLength - The target length
|
|
104
|
+
* @param padString - The string to pad with (default: ' ')
|
|
105
|
+
* @returns The padded string
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* padEnd('5', 3, '0'); // '500'
|
|
110
|
+
* padEnd('hello', 10); // 'hello '
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export declare function padEnd(str: string, targetLength: number, padString?: string): string;
|
|
114
|
+
/**
|
|
115
|
+
* Repeat a string a specified number of times.
|
|
116
|
+
*
|
|
117
|
+
* @param str - The string to repeat
|
|
118
|
+
* @param count - The number of times to repeat
|
|
119
|
+
* @returns The repeated string
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* repeat('ha', 3); // 'hahaha'
|
|
124
|
+
* repeat('*', 5); // '*****'
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export declare function repeat(str: string, count: number): string;
|
|
128
|
+
/**
|
|
129
|
+
* Count the occurrences of a substring in a string.
|
|
130
|
+
*
|
|
131
|
+
* @param str - The string to search in
|
|
132
|
+
* @param searchValue - The substring to count
|
|
133
|
+
* @param caseSensitive - Whether the search is case-sensitive (default: true)
|
|
134
|
+
* @returns The number of occurrences
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* countOccurrences('hello world hello', 'hello'); // 2
|
|
139
|
+
* countOccurrences('Hello HELLO hello', 'hello', false); // 3
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
export declare function countOccurrences(str: string, searchValue: string, caseSensitive?: boolean): number;
|
|
143
|
+
/**
|
|
144
|
+
* Extract words from a string.
|
|
145
|
+
*
|
|
146
|
+
* @param str - The string to extract words from
|
|
147
|
+
* @returns An array of words
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```typescript
|
|
151
|
+
* words('hello world'); // ['hello', 'world']
|
|
152
|
+
* words('one-two_three'); // ['one', 'two', 'three']
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
export declare function words(str: string): string[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard to check if a value is a string.
|
|
3
|
+
*
|
|
4
|
+
* @param value - The value to check
|
|
5
|
+
* @returns True if the value is a string, false otherwise
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* isString('hello'); // true
|
|
10
|
+
* isString(123); // false
|
|
11
|
+
* isString(null); // false
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function isString(value: unknown): value is string;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if a string is empty (zero length or only whitespace).
|
|
3
|
+
*
|
|
4
|
+
* @param str - The string to check
|
|
5
|
+
* @param trimWhitespace - If true, treats whitespace-only strings as empty (default: true)
|
|
6
|
+
* @returns True if the string is empty, false otherwise
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* isEmpty(''); // true
|
|
11
|
+
* isEmpty(' '); // true
|
|
12
|
+
* isEmpty(' ', false); // false
|
|
13
|
+
* isEmpty('hello'); // false
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function isEmpty(str: string, trimWhitespace?: boolean): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Check if a string contains only alphanumeric characters.
|
|
19
|
+
*
|
|
20
|
+
* @param str - The string to check
|
|
21
|
+
* @returns True if the string contains only alphanumeric characters, false otherwise
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* isAlphanumeric('abc123'); // true
|
|
26
|
+
* isAlphanumeric('abc-123'); // false
|
|
27
|
+
* isAlphanumeric(''); // false
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function isAlphanumeric(str: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Check if a string is a valid email address.
|
|
33
|
+
*
|
|
34
|
+
* @param str - The string to check
|
|
35
|
+
* @returns True if the string is a valid email address, false otherwise
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* isEmail('test@example.com'); // true
|
|
40
|
+
* isEmail('invalid-email'); // false
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function isEmail(str: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Check if a string is a valid URL.
|
|
46
|
+
*
|
|
47
|
+
* @param str - The string to check
|
|
48
|
+
* @returns True if the string is a valid URL, false otherwise
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* isUrl('https://example.com'); // true
|
|
53
|
+
* isUrl('not a url'); // false
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare function isUrl(str: string): boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixpilot/string",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"author": "Pixpilot <m.doaie@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"eslint": "^9.37.0",
|
|
32
32
|
"rollup": "^4.52.4",
|
|
33
33
|
"typescript": "^5.9.3",
|
|
34
|
-
"@internal/eslint-config": "0.3.0",
|
|
35
34
|
"@internal/prettier-config": "0.0.1",
|
|
35
|
+
"@internal/eslint-config": "0.3.0",
|
|
36
36
|
"@internal/rollup-config": "0.1.0",
|
|
37
37
|
"@internal/tsconfig": "0.1.0",
|
|
38
38
|
"@internal/vitest-config": "0.1.0"
|