@stacksjs/strings 0.58.73 → 0.59.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/dist/case.d.ts +11 -0
- package/dist/helpers.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/macro.d.ts +70 -0
- package/dist/pluralize.d.ts +23 -0
- package/dist/string.d.ts +5 -0
- package/dist/utils.d.ts +69 -0
- package/package.json +1 -1
package/dist/case.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* First letter uppercase, other lowercase
|
|
3
|
+
* @category string
|
|
4
|
+
* @example
|
|
5
|
+
* ```
|
|
6
|
+
* capitalize('hello world') => 'Hello world'
|
|
7
|
+
* ```
|
|
8
|
+
*/
|
|
9
|
+
export declare function capitalize(str: string): string;
|
|
10
|
+
export { camelCase, capitalCase, constantCase, dotCase, noCase, kebabCase, kebabCase as paramCase, pascalCase, pathCase, sentenceCase, snakeCase, split, } from 'change-case';
|
|
11
|
+
export { titleCase } from 'title-case';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function toString(v: any): string;
|
package/dist/index.d.ts
ADDED
package/dist/macro.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
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): string;
|
|
11
|
+
capitalize(str: string): string;
|
|
12
|
+
slug(str: string): string;
|
|
13
|
+
detectIndent(str: string): import("detect-indent").Indent;
|
|
14
|
+
detectNewline(str: string): "\r\n" | "\n" | 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: {
|
|
37
|
+
slash(str: string): string;
|
|
38
|
+
ensurePrefix(prefix: string, str: string): string;
|
|
39
|
+
ensureSuffix(suffix: string, str: string): string;
|
|
40
|
+
template(str: string, ...args: any[]): string;
|
|
41
|
+
/**
|
|
42
|
+
* Truncate a string
|
|
43
|
+
*/
|
|
44
|
+
truncate(str: string, length: number, end?: string): string;
|
|
45
|
+
random(length?: number): string;
|
|
46
|
+
capitalize(str: string): string;
|
|
47
|
+
slug(str: string): string;
|
|
48
|
+
detectIndent(str: string): import("detect-indent").Indent;
|
|
49
|
+
detectNewline(str: string): "\r\n" | "\n" | undefined;
|
|
50
|
+
camelCase(str: string): string;
|
|
51
|
+
capitalCase(str: string): string;
|
|
52
|
+
constantCase(str: string): string;
|
|
53
|
+
dotCase(str: string): string;
|
|
54
|
+
noCase(str: string): string;
|
|
55
|
+
paramCase(str: string): string;
|
|
56
|
+
pascalCase(str: string): string;
|
|
57
|
+
pathCase(str: string): string;
|
|
58
|
+
sentenceCase(str: string): string;
|
|
59
|
+
snakeCase(str: string): string;
|
|
60
|
+
titleCase(str: string): string;
|
|
61
|
+
kebabCase(str: string): string;
|
|
62
|
+
plural(str: string): string;
|
|
63
|
+
singular(str: string): string;
|
|
64
|
+
isPlural(str: string): boolean;
|
|
65
|
+
isSingular(str: string): boolean;
|
|
66
|
+
addPluralRule(rule: string | RegExp, repl: string): void;
|
|
67
|
+
addSingularRule(rule: string | RegExp, repl: string): void;
|
|
68
|
+
addIrregularRule(single: string, plural: string): void;
|
|
69
|
+
addUncountableRule(word: string | RegExp): void;
|
|
70
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type Rule = string | RegExp;
|
|
2
|
+
type Replacement = string;
|
|
3
|
+
type Word = string;
|
|
4
|
+
export type PluralizeTest = (word: Word) => boolean;
|
|
5
|
+
export interface Pluralize {
|
|
6
|
+
plural: (word: Word, count?: number, inclusive?: boolean) => Word;
|
|
7
|
+
singular: (word: Word) => Word;
|
|
8
|
+
isPlural: (word: Word) => boolean;
|
|
9
|
+
isSingular: (word: Word) => boolean;
|
|
10
|
+
addPluralRule: (rule: Rule, replacement: Replacement) => void;
|
|
11
|
+
addSingularRule: (rule: Rule, replacement: Replacement) => void;
|
|
12
|
+
addIrregularRule: (single: Word, plural: Word) => void;
|
|
13
|
+
addUncountableRule: (word: Word | RegExp) => void;
|
|
14
|
+
}
|
|
15
|
+
export declare const plural: Pluralize['plural'];
|
|
16
|
+
export declare const singular: Pluralize['singular'];
|
|
17
|
+
export declare const isPlural: Pluralize['isPlural'];
|
|
18
|
+
export declare const isSingular: Pluralize['isSingular'];
|
|
19
|
+
export declare const addPluralRule: Pluralize['addPluralRule'];
|
|
20
|
+
export declare const addSingularRule: Pluralize['addSingularRule'];
|
|
21
|
+
export declare const addIrregularRule: Pluralize['addIrregularRule'];
|
|
22
|
+
export declare const addUncountableRule: Pluralize['addUncountableRule'];
|
|
23
|
+
export {};
|
package/dist/string.d.ts
ADDED
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
interface SlugOptions {
|
|
2
|
+
replacement?: string;
|
|
3
|
+
remove?: RegExp;
|
|
4
|
+
lower?: boolean;
|
|
5
|
+
strict?: boolean;
|
|
6
|
+
locale?: string;
|
|
7
|
+
trim?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Replace backslash to slash
|
|
11
|
+
*
|
|
12
|
+
* @category String
|
|
13
|
+
* @example
|
|
14
|
+
* ```
|
|
15
|
+
* slash('C:\\Users\\Chris') => 'C:/Users/Chris'
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function slash(str: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Ensure prefix of a string
|
|
21
|
+
*
|
|
22
|
+
* @category String
|
|
23
|
+
* @example
|
|
24
|
+
* ```
|
|
25
|
+
* ensurePrefix('https://', 'google.com') => 'https://google.com'
|
|
26
|
+
* ensurePrefix('https://', 'http://google.com') => 'https://google.com'
|
|
27
|
+
*/
|
|
28
|
+
export declare function ensurePrefix(prefix: string, str: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Ensure suffix of a string
|
|
31
|
+
*
|
|
32
|
+
* @category String
|
|
33
|
+
* @example
|
|
34
|
+
* ```
|
|
35
|
+
* ensureSuffix('.js', 'index') => 'index.js'
|
|
36
|
+
* ensureSuffix('.js', 'index.js') => 'index.js'
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function ensureSuffix(suffix: string, str: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Dead simple template engine, just like Python's `.format()`
|
|
42
|
+
*
|
|
43
|
+
* @category String
|
|
44
|
+
* @example
|
|
45
|
+
* ```
|
|
46
|
+
* const result = template('Hello {0}! My name is {1}.',
|
|
47
|
+
* 'Buddy',
|
|
48
|
+
* 'Chris'
|
|
49
|
+
* ) // Hello Buddy! My name is Chris.
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function template(str: string, ...args: any[]): string;
|
|
53
|
+
export declare function truncate(str: string, length: number, end?: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* Generate a random string
|
|
56
|
+
* @category String
|
|
57
|
+
*/
|
|
58
|
+
export declare function random(size?: number, dict?: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Slugify a string
|
|
61
|
+
* @category string
|
|
62
|
+
* @example
|
|
63
|
+
* ```
|
|
64
|
+
* slug('Hello World') => 'hello-world'
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function slug(str: string, options?: SlugOptions): string;
|
|
68
|
+
export { default as detectIndent } from 'detect-indent';
|
|
69
|
+
export { detectNewline } from 'detect-newline';
|