@stacksjs/strings 0.70.23 → 0.70.26
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 +1 -1
- package/dist/index.js +396 -84
- package/dist/{case.d.ts → src/case.d.ts} +74 -19
- package/dist/src/detect-indent.d.ts +2 -0
- package/dist/{detect-newline.d.ts → src/detect-newline.d.ts} +1 -1
- package/dist/src/helpers.d.ts +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/macro.d.ts +36 -0
- package/dist/src/pluralize.d.ts +20 -0
- package/dist/src/slug.d.ts +13 -0
- package/dist/src/sponge-case.d.ts +2 -0
- package/dist/src/string.d.ts +7 -0
- package/dist/src/swap-case.d.ts +2 -0
- package/dist/{title-case.d.ts → src/title-case.d.ts} +1 -2
- package/dist/src/utils.d.ts +78 -0
- package/dist/{is.d.ts → src/validators.d.ts} +136 -10
- package/package.json +16 -10
- package/dist/detect-indent.d.ts +0 -9
- package/dist/helpers.d.ts +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/macro.d.ts +0 -35
- package/dist/pluralize.d.ts +0 -33
- package/dist/slug.d.ts +0 -16
- package/dist/sponge-case.d.ts +0 -1
- package/dist/string.d.ts +0 -6
- package/dist/swap-case.d.ts +0 -1
- package/dist/utils.d.ts +0 -19
|
@@ -1,36 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* First letter uppercase, other lowercase
|
|
3
|
+
* @category string
|
|
4
|
+
* @example
|
|
5
|
+
* ```
|
|
6
|
+
* capitalize('hello world') => 'Hello world'
|
|
7
|
+
* ```
|
|
8
|
+
*/
|
|
1
9
|
export declare function capitalize(str: string): string;
|
|
2
10
|
export declare function lowercase(str: string): string;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export interface PascalCaseOptions extends CaseOptions {
|
|
7
|
-
mergeAmbiguousCharacters?: boolean
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface CaseOptions {
|
|
11
|
-
locale?: Locale
|
|
12
|
-
split?: (value: string) => string[]
|
|
13
|
-
delimiter?: string
|
|
14
|
-
prefixCharacters?: string
|
|
15
|
-
suffixCharacters?: string
|
|
16
|
-
}
|
|
11
|
+
/**
|
|
12
|
+
* Split any cased input strings into an array of words.
|
|
13
|
+
*/
|
|
17
14
|
export declare function split(value: string): string[];
|
|
15
|
+
/**
|
|
16
|
+
* Split the input string into an array of words, separating numbers.
|
|
17
|
+
*/
|
|
18
18
|
export declare function splitSeparateNumbers(value: string): string[];
|
|
19
|
+
/**
|
|
20
|
+
* Convert a string to space separated lower case (`foo bar`).
|
|
21
|
+
*/
|
|
19
22
|
export declare function noCase(input: string, options?: CaseOptions): string;
|
|
23
|
+
/**
|
|
24
|
+
* Convert a string to camel case (`fooBar`).
|
|
25
|
+
*/
|
|
20
26
|
export declare function camelCase(input: string, options?: PascalCaseOptions): string;
|
|
27
|
+
/**
|
|
28
|
+
* Convert a string to pascal case (`FooBar`).
|
|
29
|
+
*/
|
|
21
30
|
export declare function pascalCase(input: string, options?: PascalCaseOptions): string;
|
|
31
|
+
/**
|
|
32
|
+
* Convert a string to pascal snake case (`Foo_Bar`).
|
|
33
|
+
*/
|
|
22
34
|
export declare function pascalSnakeCase(input: string, options?: CaseOptions): string;
|
|
35
|
+
/**
|
|
36
|
+
* Convert a string to capital case (`Foo Bar`).
|
|
37
|
+
*/
|
|
23
38
|
export declare function capitalCase(input: string, options?: CaseOptions): string;
|
|
39
|
+
/**
|
|
40
|
+
* Convert a string to constant case (`FOO_BAR`).
|
|
41
|
+
*/
|
|
24
42
|
export declare function constantCase(input: string, options?: CaseOptions): string;
|
|
43
|
+
/**
|
|
44
|
+
* Convert a string to dot case (`foo.bar`).
|
|
45
|
+
*/
|
|
25
46
|
export declare function dotCase(input: string, options?: CaseOptions): string;
|
|
47
|
+
/**
|
|
48
|
+
* Convert a string to kebab case (`foo-bar`).
|
|
49
|
+
*/
|
|
26
50
|
export declare function kebabCase(input: string, options?: CaseOptions): string;
|
|
51
|
+
/**
|
|
52
|
+
* Convert a string to path case (`foo/bar`).
|
|
53
|
+
*/
|
|
27
54
|
export declare function pathCase(input: string, options?: CaseOptions): string;
|
|
55
|
+
/**
|
|
56
|
+
* Convert a string to path case (`Foo bar`).
|
|
57
|
+
*/
|
|
28
58
|
export declare function sentenceCase(input: string, options?: CaseOptions): string;
|
|
59
|
+
/**
|
|
60
|
+
* Convert a string to snake case (`foo_bar`).
|
|
61
|
+
*/
|
|
29
62
|
export declare function snakeCase(input: string, options?: CaseOptions): string;
|
|
63
|
+
/**
|
|
64
|
+
* Convert a string to header case (`Foo-Bar`).
|
|
65
|
+
*/
|
|
30
66
|
export declare function trainCase(input: string, options?: CaseOptions): string;
|
|
31
67
|
export declare function paramCase(input: string, options?: CaseOptions): string;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
declare
|
|
36
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Options used for converting strings to pascal/camel case.
|
|
70
|
+
*/
|
|
71
|
+
export declare interface PascalCaseOptions extends CaseOptions {
|
|
72
|
+
mergeAmbiguousCharacters?: boolean
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Options used for converting strings to any case.
|
|
76
|
+
*/
|
|
77
|
+
export declare interface CaseOptions {
|
|
78
|
+
locale?: Locale
|
|
79
|
+
split?: (value: string) => string[]
|
|
80
|
+
delimiter?: string
|
|
81
|
+
prefixCharacters?: string
|
|
82
|
+
suffixCharacters?: string
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Supported locale values. Use `false` to ignore locale.
|
|
86
|
+
* Defaults to `undefined`, which uses the host environment.
|
|
87
|
+
*/
|
|
88
|
+
export type Locale = string[] | string | false | undefined;
|
|
89
|
+
export * from './sponge-case';
|
|
90
|
+
export * from './swap-case';
|
|
91
|
+
export * from './title-case';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function detectNewline(string: string): string | undefined;
|
|
2
|
-
export declare function detectNewlineGraceful(string: string): string;
|
|
2
|
+
export declare function detectNewlineGraceful(string: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function toString(v: any): string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare const Str: {
|
|
2
|
+
slash: (str: string) => string;
|
|
3
|
+
ensurePrefix: (prefix: string, str: string) => string;
|
|
4
|
+
ensureSuffix: (suffix: string, str: string) => string;
|
|
5
|
+
template: (str: string, ...args: any[]) => string;
|
|
6
|
+
/**
|
|
7
|
+
* Truncate a string
|
|
8
|
+
*/
|
|
9
|
+
truncate: (str: string, length: number, end?: string) => string;
|
|
10
|
+
random: (length?: number, dict?: string) => string;
|
|
11
|
+
capitalize: (str: string) => string;
|
|
12
|
+
slug: (str: string) => string;
|
|
13
|
+
detectIndent: (str: string) => ;
|
|
14
|
+
detectNewline: (str: string) => string | undefined;
|
|
15
|
+
camelCase: (str: string) => string;
|
|
16
|
+
capitalCase: (str: string) => string;
|
|
17
|
+
constantCase: (str: string) => string;
|
|
18
|
+
dotCase: (str: string) => string;
|
|
19
|
+
noCase: (str: string) => string;
|
|
20
|
+
paramCase: (str: string) => string;
|
|
21
|
+
pascalCase: (str: string) => string;
|
|
22
|
+
pathCase: (str: string) => string;
|
|
23
|
+
sentenceCase: (str: string) => string;
|
|
24
|
+
snakeCase: (str: string) => string;
|
|
25
|
+
titleCase: (str: string) => string;
|
|
26
|
+
kebabCase: (str: string) => string;
|
|
27
|
+
plural: (str: string) => string;
|
|
28
|
+
singular: (str: string) => string;
|
|
29
|
+
isPlural: (str: string) => boolean;
|
|
30
|
+
isSingular: (str: string) => boolean;
|
|
31
|
+
addPluralRule: (rule: string | RegExp, repl: string) => void;
|
|
32
|
+
addSingularRule: (rule: string | RegExp, repl: string) => void;
|
|
33
|
+
addIrregularRule: (single: string, plural: string) => void;
|
|
34
|
+
addUncountableRule: (word: string | RegExp) => void
|
|
35
|
+
};
|
|
36
|
+
export declare const str: typeof Str;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const pluralize: PluralizeFunction;
|
|
2
|
+
export declare const singular: PluralizeFunction;
|
|
3
|
+
export declare const plural: PluralizeFunction;
|
|
4
|
+
export declare interface PluralizeOptions {
|
|
5
|
+
count?: number
|
|
6
|
+
inclusive?: boolean
|
|
7
|
+
}
|
|
8
|
+
declare interface PluralizeFunction {
|
|
9
|
+
(word: string, options?: PluralizeOptions): string
|
|
10
|
+
plural: (word: string) => string
|
|
11
|
+
isPlural: (word: string) => boolean
|
|
12
|
+
singular: (word: string) => string
|
|
13
|
+
isSingular: (word: string) => boolean
|
|
14
|
+
addPluralRule: (rule: StringOrRegExp, replacement: string) => void
|
|
15
|
+
addSingularRule: (rule: StringOrRegExp, replacement: string) => void
|
|
16
|
+
addUncountableRule: (word: string | RegExp) => void
|
|
17
|
+
addIrregularRule: (single: string, plural: string) => void
|
|
18
|
+
}
|
|
19
|
+
declare type Rule = [RegExp, string];
|
|
20
|
+
declare type StringOrRegExp = string | RegExp;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function slugify(string: string, options?: SlugifyOptions): string;
|
|
2
|
+
export declare function extendCharMap(customMap: CharMap): void;
|
|
3
|
+
// thanks to https://github.com/simov/slugify for much of this code
|
|
4
|
+
export declare interface SlugifyOptions {
|
|
5
|
+
replacement?: string
|
|
6
|
+
remove?: RegExp
|
|
7
|
+
lower?: boolean
|
|
8
|
+
strict?: boolean
|
|
9
|
+
locale?: string
|
|
10
|
+
trim?: boolean
|
|
11
|
+
}
|
|
12
|
+
declare type CharMap = Record<string, string>;
|
|
13
|
+
declare type LocaleMap = Record<string, CharMap>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare function titleCase(input: string, options?: TitleCaseOptions | string[] | string): string;
|
|
1
2
|
export declare const WORD_SEPARATORS: Set<string>;
|
|
2
3
|
export declare const SENTENCE_TERMINATORS: Set<string>;
|
|
3
4
|
export declare const TITLE_TERMINATORS: Set<string>;
|
|
@@ -10,5 +11,3 @@ export declare interface TitleCaseOptions {
|
|
|
10
11
|
titleTerminators?: Set<string>
|
|
11
12
|
wordSeparators?: Set<string>
|
|
12
13
|
}
|
|
13
|
-
export declare function titleCase(input: string, options: TitleCaseOptions | string[] | string): string;
|
|
14
|
-
declare function upperAt(input: string, index: number, locale: string | string[] | undefined): void;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replace backslash to slash
|
|
3
|
+
*
|
|
4
|
+
* @category String
|
|
5
|
+
* @example
|
|
6
|
+
* ```
|
|
7
|
+
* slash('C:\\Users\\Chris') => 'C:/Users/Chris'
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
export declare function slash(str: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Ensure prefix of a string
|
|
13
|
+
*
|
|
14
|
+
* @category String
|
|
15
|
+
* @example
|
|
16
|
+
* ```
|
|
17
|
+
* ensurePrefix('https://', 'google.com') => 'https://google.com'
|
|
18
|
+
* ensurePrefix('https://', 'http://google.com') => 'https://google.com'
|
|
19
|
+
*/
|
|
20
|
+
export declare function ensurePrefix(prefix: string, str: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Ensure suffix of a string
|
|
23
|
+
*
|
|
24
|
+
* @category String
|
|
25
|
+
* @example
|
|
26
|
+
* ```
|
|
27
|
+
* ensureSuffix('.js', 'index') => 'index.js'
|
|
28
|
+
* ensureSuffix('.js', 'index.js') => 'index.js'
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function ensureSuffix(suffix: string, str: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Dead simple template engine, just like Python's `.format()`
|
|
34
|
+
*
|
|
35
|
+
* @category String
|
|
36
|
+
* @example
|
|
37
|
+
* ```
|
|
38
|
+
* const result = template('Hello {0}! My name is {1}.',
|
|
39
|
+
* 'Buddy',
|
|
40
|
+
* 'Chris'
|
|
41
|
+
* ) // Hello Buddy! My name is Chris.
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function template(str: string, ...args: any[]): string;
|
|
45
|
+
export declare function truncate(str: string, length: number, end?: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Generate a random string.
|
|
48
|
+
*
|
|
49
|
+
* Uses `crypto.getRandomValues()` so the result is suitable for tokens,
|
|
50
|
+
* password reset codes, API keys, and any other security-sensitive use —
|
|
51
|
+
* `Math.random()` is predictable and would let an attacker reproduce
|
|
52
|
+
* "random" tokens given enough sample output.
|
|
53
|
+
*
|
|
54
|
+
* @category String
|
|
55
|
+
*/
|
|
56
|
+
export declare function random(size?: number, dict?: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* Slugify a string
|
|
59
|
+
* @category string
|
|
60
|
+
* @example
|
|
61
|
+
* ```
|
|
62
|
+
* slug('Hello World') => 'hello-world'
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function slug(str: string, options?: SlugOptions): string;
|
|
66
|
+
// port from nanoid
|
|
67
|
+
// https://github.com/ai/nanoid
|
|
68
|
+
export declare const urlAlphabet: 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
|
|
69
|
+
declare interface SlugOptions {
|
|
70
|
+
replacement?: string
|
|
71
|
+
remove?: RegExp
|
|
72
|
+
lower?: boolean
|
|
73
|
+
strict?: boolean
|
|
74
|
+
locale?: string
|
|
75
|
+
trim?: boolean
|
|
76
|
+
}
|
|
77
|
+
export * from './detect-indent';
|
|
78
|
+
export * from './detect-newline';
|
|
@@ -1,44 +1,170 @@
|
|
|
1
1
|
import type { HashAlgorithm } from '@stacksjs/types';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Email validation
|
|
4
|
+
*/
|
|
3
5
|
export declare function isEmail(email: string): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Strong password validation
|
|
8
|
+
* Must contain: min 8 chars, uppercase, lowercase, number, symbol
|
|
9
|
+
*/
|
|
4
10
|
export declare function isStrongPassword(password: string): boolean;
|
|
5
|
-
|
|
6
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Alphanumeric validation (letters and numbers only)
|
|
13
|
+
*/
|
|
14
|
+
export declare function isAlphanumeric(str: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* URL validation
|
|
17
|
+
*/
|
|
7
18
|
export declare function isURL(url: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Mobile phone validation (international format)
|
|
21
|
+
*/
|
|
8
22
|
export declare function isMobilePhone(phoneNumber: string): boolean;
|
|
9
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Alphabetic characters only
|
|
25
|
+
*/
|
|
26
|
+
export declare function isAlpha(str: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Postal code validation (supports multiple formats)
|
|
29
|
+
*/
|
|
10
30
|
export declare function isPostalCode(zipCode: string): boolean;
|
|
11
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Numeric string validation
|
|
33
|
+
*/
|
|
34
|
+
export declare function isNumeric(str: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Hex color validation
|
|
37
|
+
*/
|
|
12
38
|
export declare function isHexColor(color: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Hexadecimal validation
|
|
41
|
+
*/
|
|
13
42
|
export declare function isHexadecimal(hex: string): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Base64 validation
|
|
45
|
+
*/
|
|
14
46
|
export declare function isBase64(base64: string): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* UUID validation (v1-v5)
|
|
49
|
+
*/
|
|
15
50
|
export declare function isUUID(uuid: string): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* JSON validation
|
|
53
|
+
*/
|
|
16
54
|
export declare function isJSON(json: string): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Credit card validation (Luhn algorithm)
|
|
57
|
+
*/
|
|
17
58
|
export declare function isCreditCard(creditCard: string): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* ISBN validation (ISBN-10 and ISBN-13)
|
|
61
|
+
*/
|
|
18
62
|
export declare function isISBN(isbn: string): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* IP address validation (IPv4 and IPv6)
|
|
65
|
+
*/
|
|
19
66
|
export declare function isIP(ip: string): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* IP range validation (CIDR notation)
|
|
69
|
+
*/
|
|
20
70
|
export declare function isIPRange(ip: string): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* MAC address validation
|
|
73
|
+
*/
|
|
21
74
|
export declare function isMACAddress(macAddress: string): boolean;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Latitude/Longitude validation
|
|
77
|
+
*/
|
|
78
|
+
export declare function isLatLong(latlong: string): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Currency validation
|
|
81
|
+
*/
|
|
25
82
|
export declare function isCurrency(currency: string): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Data URI validation
|
|
85
|
+
*/
|
|
26
86
|
export declare function isDataURI(dataURI: string): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* MIME type validation
|
|
89
|
+
*/
|
|
27
90
|
export declare function isMimeType(mimeType: string): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* JWT validation
|
|
93
|
+
*/
|
|
28
94
|
export declare function isJWT(jwt: string): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* ASCII validation
|
|
97
|
+
*/
|
|
29
98
|
export declare function isAscii(ascii: string): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Base32 validation
|
|
101
|
+
*/
|
|
30
102
|
export declare function isBase32(base32: string): boolean;
|
|
31
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Byte length validation
|
|
105
|
+
*/
|
|
106
|
+
export declare function isByteLength(str: string, options?: { min?: number, max?: number }): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* FQDN validation (Fully Qualified Domain Name)
|
|
109
|
+
*/
|
|
32
110
|
export declare function isFQDN(fqdn: string): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Full width character validation
|
|
113
|
+
*/
|
|
33
114
|
export declare function isFullWidth(fullWidth: string): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Half width character validation
|
|
117
|
+
*/
|
|
34
118
|
export declare function isHalfWidth(halfWidth: string): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Hash validation for various algorithms
|
|
121
|
+
*/
|
|
35
122
|
export declare function isHash(hash: string, algorithm: HashAlgorithm): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* HSL color validation
|
|
125
|
+
*/
|
|
36
126
|
export declare function isHSL(hsl: string): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* IBAN validation
|
|
129
|
+
*/
|
|
37
130
|
export declare function isIBAN(iban: string): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Identity card validation
|
|
133
|
+
*/
|
|
38
134
|
export declare function isIdentityCard(identityCard: string): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* ISIN validation
|
|
137
|
+
*/
|
|
39
138
|
export declare function isISIN(isin: string): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* ISO 8601 date validation
|
|
141
|
+
*/
|
|
40
142
|
export declare function isISO8601(iso8601: string): boolean;
|
|
143
|
+
/**
|
|
144
|
+
* ISRC validation
|
|
145
|
+
*/
|
|
41
146
|
export declare function isISRC(isrc: string): boolean;
|
|
147
|
+
/**
|
|
148
|
+
* ISSN validation
|
|
149
|
+
*/
|
|
42
150
|
export declare function isISSN(issn: string): boolean;
|
|
151
|
+
/**
|
|
152
|
+
* ISO 3166-1 alpha-2 country code validation
|
|
153
|
+
*/
|
|
43
154
|
export declare function isISO31661Alpha2(iso31661Alpha2: string): boolean;
|
|
44
|
-
|
|
155
|
+
/**
|
|
156
|
+
* ISO 3166-1 alpha-3 country code validation
|
|
157
|
+
*/
|
|
158
|
+
export declare function isISO31661Alpha3(iso31661Alpha3: string): boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Username validation
|
|
161
|
+
*/
|
|
162
|
+
export declare function validateUsername(username: string): boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Latitude validation
|
|
165
|
+
*/
|
|
166
|
+
export declare function isLatitude(latitude: string): boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Longitude validation
|
|
169
|
+
*/
|
|
170
|
+
export declare function isLongitude(longitude: string): boolean;
|
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/strings",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.70.
|
|
4
|
+
"version": "0.70.26",
|
|
5
5
|
"description": "The Stacks string utilities.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
|
-
"contributors": [
|
|
7
|
+
"contributors": [
|
|
8
|
+
"Chris Breuer <chris@stacksjs.com>"
|
|
9
|
+
],
|
|
8
10
|
"license": "MIT",
|
|
9
11
|
"funding": "https://github.com/sponsors/chrisbbreuer",
|
|
10
12
|
"homepage": "https://github.com/stacksjs/stacks/tree/main/storage/framework/core/strings#readme",
|
|
@@ -36,15 +38,21 @@
|
|
|
36
38
|
],
|
|
37
39
|
"exports": {
|
|
38
40
|
".": {
|
|
41
|
+
"types": "./dist/index.d.ts",
|
|
42
|
+
"bun": "./src/index.ts",
|
|
39
43
|
"import": "./dist/index.js"
|
|
40
44
|
},
|
|
41
45
|
"./*": {
|
|
46
|
+
"bun": "./src/*",
|
|
42
47
|
"import": "./dist/*"
|
|
43
48
|
}
|
|
44
49
|
},
|
|
45
50
|
"module": "dist/index.js",
|
|
46
51
|
"types": "dist/index.d.ts",
|
|
47
|
-
"files": [
|
|
52
|
+
"files": [
|
|
53
|
+
"README.md",
|
|
54
|
+
"dist"
|
|
55
|
+
],
|
|
48
56
|
"scripts": {
|
|
49
57
|
"build": "bun build.ts",
|
|
50
58
|
"typecheck": "bun tsc --noEmit",
|
|
@@ -52,11 +60,9 @@
|
|
|
52
60
|
"prepublishOnly": "bun run build"
|
|
53
61
|
},
|
|
54
62
|
"devDependencies": {
|
|
55
|
-
"@stacksjs/alias": "0.70.
|
|
56
|
-
"
|
|
57
|
-
"@stacksjs/types": "0.70.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"validator": "^13.15.0"
|
|
61
|
-
}
|
|
63
|
+
"@stacksjs/alias": "0.70.23",
|
|
64
|
+
"better-dx": "^0.2.12",
|
|
65
|
+
"@stacksjs/types": "0.70.23"
|
|
66
|
+
},
|
|
67
|
+
"sideEffects": false
|
|
62
68
|
}
|
package/dist/detect-indent.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare const INDENT_TYPE_SPACE: 'space' const INDENT_TYPE_TAB = 'tab';
|
|
2
|
-
declare function makeIndentsMap(string: string, ignoreSingleSpaces: boolean): void;
|
|
3
|
-
declare function encodeIndentsKey(indentType: any, indentAmount: any): void;
|
|
4
|
-
declare function decodeIndentsKey(indentsKey: any): void;
|
|
5
|
-
declare function getMostUsedKey(indents: any): void;
|
|
6
|
-
declare function makeIndentString(type: any, amount: any): void;
|
|
7
|
-
export declare function detectIndent(string: string): void;
|
|
8
|
-
|
|
9
|
-
export default detectIndent;
|
package/dist/helpers.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function toString(v: any): string;
|
package/dist/index.d.ts
DELETED
package/dist/macro.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export declare const Str: {
|
|
2
|
-
slash: (str: string) => void;
|
|
3
|
-
ensurePrefix: (prefix: string, str: string) => void;
|
|
4
|
-
ensureSuffix: (suffix: string, str: string) => void;
|
|
5
|
-
template: (str: string, ...args: any[]) => void;
|
|
6
|
-
* Truncate a string
|
|
7
|
-
*/
|
|
8
|
-
truncate: () => unknown;
|
|
9
|
-
random: (length, dict?: string) => void;
|
|
10
|
-
capitalize: (str: string) => void;
|
|
11
|
-
slug: (str: string) => void;
|
|
12
|
-
detectIndent: (str: string) => void;
|
|
13
|
-
detectNewline: (str: string) => void;
|
|
14
|
-
camelCase: (str: string) => void;
|
|
15
|
-
capitalCase: (str: string) => void;
|
|
16
|
-
constantCase: (str: string) => void;
|
|
17
|
-
dotCase: (str: string) => void;
|
|
18
|
-
noCase: (str: string) => void;
|
|
19
|
-
paramCase: (str: string) => void;
|
|
20
|
-
pascalCase: (str: string) => void;
|
|
21
|
-
pathCase: (str: string) => void;
|
|
22
|
-
sentenceCase: (str: string) => void;
|
|
23
|
-
snakeCase: (str: string) => void;
|
|
24
|
-
titleCase: (str: string) => void;
|
|
25
|
-
kebabCase: (str: string) => void;
|
|
26
|
-
plural: (str: string) => void;
|
|
27
|
-
singular: (str: string) => void;
|
|
28
|
-
isPlural: (str: string) => void;
|
|
29
|
-
isSingular: (str: string) => void;
|
|
30
|
-
addPluralRule: (rule: string | RegExp, repl: string) => void;
|
|
31
|
-
addSingularRule: (rule: string | RegExp, repl: string) => void;
|
|
32
|
-
addIrregularRule: (single: string, plural: string) => void;
|
|
33
|
-
addUncountableRule: (word: string | RegExp) => void
|
|
34
|
-
};
|
|
35
|
-
export declare const str: typeof Str;
|
package/dist/pluralize.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export declare interface PluralizeOptions {
|
|
2
|
-
count?: number
|
|
3
|
-
inclusive?: boolean
|
|
4
|
-
}
|
|
5
|
-
declare type Rule = [RegExp, string]
|
|
6
|
-
type StringOrRegExp = string | RegExp
|
|
7
|
-
|
|
8
|
-
interface PluralizeFunction {
|
|
9
|
-
(word: string, options?: PluralizeOptions): string
|
|
10
|
-
plural: (word: string) => string
|
|
11
|
-
isPlural: (word: string) => boolean
|
|
12
|
-
singular: (word: string) => string
|
|
13
|
-
isSingular: (word: string) => boolean
|
|
14
|
-
addPluralRule: (rule: StringOrRegExp, replacement: string) => void
|
|
15
|
-
addSingularRule: (rule: StringOrRegExp, replacement: string) => void
|
|
16
|
-
addUncountableRule: (word: string | RegExp) => void
|
|
17
|
-
addIrregularRule: (single: string, plural: string) => void
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const pluralRules: Rule[] = []
|
|
21
|
-
const singularRules: Rule[] = []
|
|
22
|
-
const uncountables: Record<string, boolean> = {}
|
|
23
|
-
const irregularPlurals: Record<string, string> = {}
|
|
24
|
-
const irregularSingles: Record<string, string> = {}
|
|
25
|
-
declare function sanitizeRule(rule: string | RegExp): RegExp;
|
|
26
|
-
declare function restoreCase(word: string, token: string): string;
|
|
27
|
-
declare function interpolate(str: string, ...args: any[]): string;
|
|
28
|
-
declare function replace(word: string, rule: Rule): string;
|
|
29
|
-
declare function sanitizeWord(token: string, word: string, rules: Rule[]): string;
|
|
30
|
-
declare function replaceWord(replaceMap: Record<string, string>, keepMap: Record<string, string>, rules: Rule[]): (word: string) => string;
|
|
31
|
-
declare function checkWord(replaceMap: Record<string, string>, keepMap: Record<string, string>, rules: Rule[]): (word: string) => boolean;
|
|
32
|
-
|
|
33
|
-
export default pluralize;
|