@stacksjs/strings 0.59.10 → 0.61.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/index.js +12 -8
- package/package.json +6 -5
- package/src/is.ts +42 -42
- package/src/pluralize.ts +16 -8
- package/src/utils.ts +4 -8
- package/dist/case.d.ts +0 -11
- package/dist/helpers.d.ts +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/macro.d.ts +0 -70
- package/dist/pluralize.d.ts +0 -23
- package/dist/string.d.ts +0 -5
- package/dist/utils.d.ts +0 -69
package/dist/index.js
CHANGED
|
@@ -248,14 +248,18 @@ split
|
|
|
248
248
|
import {titleCase} from "title-case";
|
|
249
249
|
// src/pluralize.ts
|
|
250
250
|
import * as pluralize from "pluralize";
|
|
251
|
-
var plural2 = (
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
var
|
|
257
|
-
var
|
|
258
|
-
var
|
|
251
|
+
var plural2 = (word, count, inclusive) => {
|
|
252
|
+
if (count !== undefined && inclusive)
|
|
253
|
+
return `${count} ${pluralize.plural(word)}`;
|
|
254
|
+
return pluralize.plural(word);
|
|
255
|
+
};
|
|
256
|
+
var singular2 = (word) => pluralize.singular(word);
|
|
257
|
+
var isPlural2 = (word) => pluralize.isPlural(word);
|
|
258
|
+
var isSingular2 = (word) => pluralize.isSingular(word);
|
|
259
|
+
var addPluralRule2 = (rule, replacement) => pluralize.addPluralRule(rule, replacement);
|
|
260
|
+
var addSingularRule2 = (rule, replacement) => pluralize.addSingularRule(rule, replacement);
|
|
261
|
+
var addIrregularRule2 = (single, plural3) => pluralize.addIrregularRule(single, plural3);
|
|
262
|
+
var addUncountableRule2 = (word) => pluralize.addUncountableRule(word);
|
|
259
263
|
// src/macro.ts
|
|
260
264
|
var Str = {
|
|
261
265
|
slash(str) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/strings",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.61.0",
|
|
5
5
|
"description": "The Stacks string utilities.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"license": "MIT",
|
|
@@ -65,18 +65,19 @@
|
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@stacksjs/alias": "latest",
|
|
67
67
|
"@stacksjs/types": "latest",
|
|
68
|
-
"change-case": "^5.4.
|
|
68
|
+
"change-case": "^5.4.4",
|
|
69
69
|
"detect-indent": "^7.0.1",
|
|
70
70
|
"detect-newline": "^4.0.1",
|
|
71
71
|
"macroable": "^7.0.2",
|
|
72
72
|
"pluralize": "^8.0.0",
|
|
73
73
|
"slugify": "^1.6.6",
|
|
74
|
-
"string-ts": "^2.
|
|
74
|
+
"string-ts": "^2.1.1",
|
|
75
75
|
"title-case": "^4.3.1",
|
|
76
|
-
"validator": "^13.
|
|
76
|
+
"validator": "^13.12.0"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@stacksjs/development": "latest",
|
|
80
|
-
"@types/
|
|
80
|
+
"@types/pluralize": "^0.0.33",
|
|
81
|
+
"@types/validator": "^13.11.10"
|
|
81
82
|
}
|
|
82
83
|
}
|
package/src/is.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { HashAlgorithm } from '@stacksjs/types'
|
|
2
|
-
import
|
|
2
|
+
import validator from 'validator'
|
|
3
3
|
|
|
4
4
|
export function isEmail(email: string) {
|
|
5
|
-
return
|
|
5
|
+
return validator.isEmail(email)
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export function isStrongPassword(password: string) {
|
|
9
|
-
return
|
|
9
|
+
return validator.isStrongPassword(password)
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export function isAlphanumeric(username: string) {
|
|
13
|
-
return
|
|
13
|
+
return validator.isAlphanumeric(username)
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export function validateUsername(username: string) {
|
|
@@ -18,153 +18,153 @@ export function validateUsername(username: string) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export function isURL(url: string) {
|
|
21
|
-
return
|
|
21
|
+
return validator.isURL(url)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export function isMobilePhone(phoneNumber: string) {
|
|
25
|
-
return
|
|
25
|
+
return validator.isMobilePhone(phoneNumber)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export function isAlpha(name: string) {
|
|
29
|
-
return
|
|
29
|
+
return validator.isAlpha(name)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export function isPostalCode(zipCode: string) {
|
|
33
|
-
return
|
|
33
|
+
return validator.isPostalCode(zipCode, 'any')
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export function isNumeric(number: string) {
|
|
37
|
-
return
|
|
37
|
+
return validator.isNumeric(number)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export function isHexColor(color: string) {
|
|
41
|
-
return
|
|
41
|
+
return validator.isHexColor(color)
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export function isHexadecimal(hex: string) {
|
|
45
|
-
return
|
|
45
|
+
return validator.isHexadecimal(hex)
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
export function isBase64(base64: string) {
|
|
49
|
-
return
|
|
49
|
+
return validator.isBase64(base64)
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
export function isUUID(uuid: string) {
|
|
53
|
-
return
|
|
53
|
+
return validator.isUUID(uuid)
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
export function isJSON(json: string) {
|
|
57
|
-
return
|
|
57
|
+
return validator.isJSON(json)
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
export function isCreditCard(creditCard: string) {
|
|
61
|
-
return
|
|
61
|
+
return validator.isCreditCard(creditCard)
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
export function isISBN(isbn: string) {
|
|
65
|
-
return
|
|
65
|
+
return validator.isISBN(isbn)
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
export function isIP(ip: string) {
|
|
69
|
-
return
|
|
69
|
+
return validator.isIP(ip)
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
export function isIPRange(ip: string) {
|
|
73
|
-
return
|
|
73
|
+
return validator.isIPRange(ip)
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
export function isMACAddress(macAddress: string) {
|
|
77
|
-
return
|
|
77
|
+
return validator.isMACAddress(macAddress)
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
export function isLatLong(latitude: string) {
|
|
81
|
-
return
|
|
81
|
+
return validator.isLatLong(latitude)
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
export function isLatitude(longitude: string) {
|
|
85
|
-
return
|
|
85
|
+
return validator.isLatLong(longitude)
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
export function isLongitude(longitude: string) {
|
|
89
|
-
return
|
|
89
|
+
return validator.isLatLong(longitude)
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
export function isCurrency(currency: string) {
|
|
93
|
-
return
|
|
93
|
+
return validator.isCurrency(currency)
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
export function isDataURI(dataURI: string) {
|
|
97
|
-
return
|
|
97
|
+
return validator.isDataURI(dataURI)
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
export function isMimeType(mimeType: string) {
|
|
101
|
-
return
|
|
101
|
+
return validator.isMimeType(mimeType)
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
export function isJWT(jwt: string) {
|
|
105
|
-
return
|
|
105
|
+
return validator.isJWT(jwt)
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
export function isAscii(ascii: string) {
|
|
109
|
-
return
|
|
109
|
+
return validator.isAscii(ascii)
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
export function isBase32(base32: string) {
|
|
113
|
-
return
|
|
113
|
+
return validator.isBase32(base32)
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
export function isByteLength(byteLength: string) {
|
|
117
|
-
return
|
|
117
|
+
return validator.isByteLength(byteLength)
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
export function isFQDN(fqdn: string) {
|
|
121
|
-
return
|
|
121
|
+
return validator.isFQDN(fqdn)
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
export function isFullWidth(fullWidth: string) {
|
|
125
|
-
return
|
|
125
|
+
return validator.isFullWidth(fullWidth)
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
export function isHalfWidth(halfWidth: string) {
|
|
129
|
-
return
|
|
129
|
+
return validator.isHalfWidth(halfWidth)
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
export function isHash(hash: string, algorithm: HashAlgorithm) {
|
|
133
|
-
return
|
|
133
|
+
return validator.isHash(hash, algorithm)
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
export function isHSL(hsl: string) {
|
|
137
|
-
return
|
|
137
|
+
return validator.isHSL(hsl)
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
export function isIBAN(iban: string) {
|
|
141
|
-
return
|
|
141
|
+
return validator.isIBAN(iban)
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
export function isIdentityCard(identityCard: string) {
|
|
145
|
-
return
|
|
145
|
+
return validator.isIdentityCard(identityCard)
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
export function isISIN(isin: string) {
|
|
149
|
-
return
|
|
149
|
+
return validator.isISIN(isin)
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
export function isISO8601(iso8601: string) {
|
|
153
|
-
return
|
|
153
|
+
return validator.isISO8601(iso8601)
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
export function isISRC(isrc: string) {
|
|
157
|
-
return
|
|
157
|
+
return validator.isISRC(isrc)
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
export function isISSN(issn: string) {
|
|
161
|
-
return
|
|
161
|
+
return validator.isISSN(issn)
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
export function isISO31661Alpha2(iso31661Alpha2: string) {
|
|
165
|
-
return
|
|
165
|
+
return validator.isISO31661Alpha2(iso31661Alpha2)
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
export function isISO31661Alpha3(iso31661Alpha3: string) {
|
|
169
|
-
return
|
|
169
|
+
return validator.isISO31661Alpha3(iso31661Alpha3)
|
|
170
170
|
}
|
package/src/pluralize.ts
CHANGED
|
@@ -16,11 +16,19 @@ export interface Pluralize {
|
|
|
16
16
|
addUncountableRule: (word: Word | RegExp) => void
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export const plural: Pluralize['plural'] = (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export const
|
|
26
|
-
export const
|
|
19
|
+
export const plural: Pluralize['plural'] = (word, count, inclusive) => {
|
|
20
|
+
if (count !== undefined && inclusive) return `${count} ${pluralize.plural(word)}`
|
|
21
|
+
|
|
22
|
+
return pluralize.plural(word)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const singular: Pluralize['singular'] = (word) => pluralize.singular(word)
|
|
26
|
+
export const isPlural: Pluralize['isPlural'] = (word) => pluralize.isPlural(word)
|
|
27
|
+
export const isSingular: Pluralize['isSingular'] = (word) => pluralize.isSingular(word)
|
|
28
|
+
export const addPluralRule: Pluralize['addPluralRule'] = (rule, replacement) =>
|
|
29
|
+
pluralize.addPluralRule(rule, replacement)
|
|
30
|
+
export const addSingularRule: Pluralize['addSingularRule'] = (rule, replacement) =>
|
|
31
|
+
pluralize.addSingularRule(rule, replacement)
|
|
32
|
+
export const addIrregularRule: Pluralize['addIrregularRule'] = (single, plural) =>
|
|
33
|
+
pluralize.addIrregularRule(single, plural)
|
|
34
|
+
export const addUncountableRule: Pluralize['addUncountableRule'] = (word) => pluralize.addUncountableRule(word)
|
package/src/utils.ts
CHANGED
|
@@ -36,8 +36,7 @@ export function slash(str: string) {
|
|
|
36
36
|
* ensurePrefix('https://', 'http://google.com') => 'https://google.com'
|
|
37
37
|
*/
|
|
38
38
|
export function ensurePrefix(prefix: string, str: string) {
|
|
39
|
-
if (!str.startsWith(prefix))
|
|
40
|
-
return prefix + str
|
|
39
|
+
if (!str.startsWith(prefix)) return prefix + str
|
|
41
40
|
return str
|
|
42
41
|
}
|
|
43
42
|
|
|
@@ -76,8 +75,7 @@ export function template(str: string, ...args: any[]): string {
|
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
export function truncate(str: string, length: number, end = '...') {
|
|
79
|
-
if (str.length <= length)
|
|
80
|
-
return str
|
|
78
|
+
if (str.length <= length) return str
|
|
81
79
|
|
|
82
80
|
return str.slice(0, length - end.length) + end
|
|
83
81
|
}
|
|
@@ -90,8 +88,7 @@ export function random(size = 16, dict = urlAlphabet) {
|
|
|
90
88
|
let id = ''
|
|
91
89
|
let i = size
|
|
92
90
|
const len = dict.length
|
|
93
|
-
while (i--)
|
|
94
|
-
id += dict[(Math.random() * len) | 0]
|
|
91
|
+
while (i--) id += dict[(Math.random() * len) | 0]
|
|
95
92
|
return id
|
|
96
93
|
}
|
|
97
94
|
|
|
@@ -104,8 +101,7 @@ export function random(size = 16, dict = urlAlphabet) {
|
|
|
104
101
|
* ```
|
|
105
102
|
*/
|
|
106
103
|
export function slug(str: string, options?: SlugOptions): string {
|
|
107
|
-
if (options)
|
|
108
|
-
return slugify(str, options)
|
|
104
|
+
if (options) return slugify(str, options)
|
|
109
105
|
|
|
110
106
|
return slugify(str, {
|
|
111
107
|
lower: true,
|
package/dist/case.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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';
|
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,70 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/pluralize.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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
DELETED
package/dist/utils.d.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
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';
|