@stacksjs/strings 0.57.4 โ 0.58.19
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 +73 -13
- package/dist/index.js +393 -0
- package/package.json +32 -28
- package/LICENSE.md +0 -21
- package/dist/case.d.ts +0 -11
- package/dist/case.mjs +0 -18
- package/dist/index.d.ts +0 -4
- package/dist/index.mjs +0 -4
- package/dist/is.d.ts +0 -43
- package/dist/is.mjs +0 -127
- package/dist/macro.d.ts +0 -40
- package/dist/macro.mjs +0 -105
- package/dist/pluralize.d.ts +0 -2
- package/dist/pluralize.mjs +0 -3
- package/dist/utils.d.ts +0 -69
- package/dist/utils.mjs +0 -46
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Easily manipulate & work with strings.
|
|
|
10
10
|
## ๐ค Usage
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
|
|
13
|
+
bun install -d @stacksjs/strings
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
Now, you can use it in your project:
|
|
@@ -18,28 +18,88 @@ Now, you can use it in your project:
|
|
|
18
18
|
```js
|
|
19
19
|
import {
|
|
20
20
|
// pluralize
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
addIrregularRule,
|
|
22
|
+
addPluralRule,
|
|
23
|
+
addSingularRule,
|
|
24
|
+
addUncountableRule,
|
|
25
|
+
isPlural,
|
|
26
|
+
isSingular,
|
|
27
|
+
singular,
|
|
28
|
+
plural,
|
|
23
29
|
|
|
24
30
|
// case
|
|
25
|
-
camelCase,
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
camelCase,
|
|
32
|
+
capitalCase,
|
|
33
|
+
constantCase,
|
|
34
|
+
dotCase,
|
|
35
|
+
headerCase,
|
|
36
|
+
kebabCase,
|
|
37
|
+
noCase,
|
|
38
|
+
paramCase,
|
|
39
|
+
pascalCase,
|
|
40
|
+
pathCase,
|
|
41
|
+
sentenceCase,
|
|
42
|
+
snakeCase,
|
|
43
|
+
titleCase,
|
|
28
44
|
|
|
29
45
|
// validation
|
|
30
|
-
isEmail,
|
|
46
|
+
isEmail,
|
|
47
|
+
isStrongPassword,
|
|
48
|
+
isAlphanumeric,
|
|
49
|
+
validateUsername,
|
|
50
|
+
isURL,
|
|
51
|
+
isMobilePhone,
|
|
52
|
+
isAlpha,
|
|
53
|
+
isPostalCode,
|
|
54
|
+
isDate,
|
|
55
|
+
isNumeric,
|
|
56
|
+
isBoolean,
|
|
57
|
+
isHexColor,
|
|
58
|
+
isHexadecimal,
|
|
59
|
+
isBase64,
|
|
60
|
+
isUUID,
|
|
61
|
+
isJSON,
|
|
62
|
+
isCreditCard,
|
|
63
|
+
isISBN,
|
|
64
|
+
isIP,
|
|
65
|
+
isIPRange,
|
|
66
|
+
isMACAddress,
|
|
67
|
+
isLatLong,
|
|
68
|
+
isLatitude,
|
|
69
|
+
isLongitude,
|
|
70
|
+
isCurrency,
|
|
71
|
+
isDataURI,
|
|
72
|
+
isMimeType,
|
|
73
|
+
isJWT,
|
|
74
|
+
isMongoId,
|
|
75
|
+
isAscii,
|
|
76
|
+
isBase32,
|
|
77
|
+
isByteLength,
|
|
78
|
+
isFQDN,
|
|
79
|
+
isFullWidth,
|
|
80
|
+
isHalfWidth,
|
|
81
|
+
isHash,
|
|
82
|
+
isHSL,
|
|
83
|
+
isIBAN,
|
|
84
|
+
isIdentityCard,
|
|
85
|
+
isISIN,
|
|
86
|
+
isISO8601,
|
|
87
|
+
isISRC,
|
|
88
|
+
isISSN,
|
|
89
|
+
isISO31661Alpha2,
|
|
90
|
+
isISO31661Alpha3
|
|
31
91
|
} from '@stacksjs/strings'
|
|
32
92
|
|
|
33
|
-
console.log(camelCase('hello world'))
|
|
34
|
-
console.log(plural('dog'))
|
|
93
|
+
console.log(camelCase('hello world')) // => "helloWorld"
|
|
94
|
+
console.log(plural('dog')) // => "dogs"
|
|
35
95
|
```
|
|
36
96
|
|
|
37
|
-
To view the full documentation, please visit [https://stacksjs.
|
|
97
|
+
To view the full documentation, please visit [https://stacksjs.org/strings](https://stacksjs.org/strings).
|
|
38
98
|
|
|
39
99
|
## ๐งช Testing
|
|
40
100
|
|
|
41
101
|
```bash
|
|
42
|
-
|
|
102
|
+
bun test
|
|
43
103
|
```
|
|
44
104
|
|
|
45
105
|
## ๐ Changelog
|
|
@@ -58,7 +118,7 @@ For help, discussion about best practices, or any other conversation that would
|
|
|
58
118
|
|
|
59
119
|
For casual chit-chat with others using this package:
|
|
60
120
|
|
|
61
|
-
[Join the Stacks Discord Server](https://discord.
|
|
121
|
+
[Join the Stacks Discord Server](https://discord.gg/stacksjs)
|
|
62
122
|
|
|
63
123
|
## ๐๐ผ Credits
|
|
64
124
|
|
|
@@ -74,4 +134,4 @@ Many thanks to the following core technologies & people who have contributed to
|
|
|
74
134
|
|
|
75
135
|
The MIT License (MIT). Please see [LICENSE](https://github.com/stacksjs/stacks/tree/main/LICENSE.md) for more information.
|
|
76
136
|
|
|
77
|
-
Made with
|
|
137
|
+
Made with ๐
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, {
|
|
5
|
+
get: all[name],
|
|
6
|
+
enumerable: true,
|
|
7
|
+
configurable: true,
|
|
8
|
+
set: (newValue) => all[name] = () => newValue
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// src/string.ts
|
|
13
|
+
var exports_string = {};
|
|
14
|
+
__export(exports_string, {
|
|
15
|
+
truncate: () => {
|
|
16
|
+
{
|
|
17
|
+
return truncate;
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
toString: () => {
|
|
21
|
+
{
|
|
22
|
+
return toString;
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
titleCase: () => {
|
|
26
|
+
{
|
|
27
|
+
return titleCase;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
template: () => {
|
|
31
|
+
{
|
|
32
|
+
return template;
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
str: () => {
|
|
36
|
+
{
|
|
37
|
+
return str;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
split: () => {
|
|
41
|
+
{
|
|
42
|
+
return split;
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
snakeCase: () => {
|
|
46
|
+
{
|
|
47
|
+
return snakeCase;
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
slug: () => {
|
|
51
|
+
{
|
|
52
|
+
return slug;
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
slash: () => {
|
|
56
|
+
{
|
|
57
|
+
return slash;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
singular: () => {
|
|
61
|
+
{
|
|
62
|
+
return singular2;
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
sentenceCase: () => {
|
|
66
|
+
{
|
|
67
|
+
return sentenceCase;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
random: () => {
|
|
71
|
+
{
|
|
72
|
+
return random;
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
plural: () => {
|
|
76
|
+
{
|
|
77
|
+
return plural2;
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
pathCase: () => {
|
|
81
|
+
{
|
|
82
|
+
return pathCase;
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
pascalCase: () => {
|
|
86
|
+
{
|
|
87
|
+
return pascalCase;
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
paramCase: () => {
|
|
91
|
+
{
|
|
92
|
+
return kebabCase2;
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
noCase: () => {
|
|
96
|
+
{
|
|
97
|
+
return noCase;
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
kebabCase: () => {
|
|
101
|
+
{
|
|
102
|
+
return kebabCase;
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
isSingular: () => {
|
|
106
|
+
{
|
|
107
|
+
return isSingular2;
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
isPlural: () => {
|
|
111
|
+
{
|
|
112
|
+
return isPlural2;
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
ensureSuffix: () => {
|
|
116
|
+
{
|
|
117
|
+
return ensureSuffix;
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
ensurePrefix: () => {
|
|
121
|
+
{
|
|
122
|
+
return ensurePrefix;
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
dotCase: () => {
|
|
126
|
+
{
|
|
127
|
+
return dotCase;
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
detectNewline: () => {
|
|
131
|
+
{
|
|
132
|
+
return detectNewline;
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
detectIndent: () => {
|
|
136
|
+
{
|
|
137
|
+
return default2;
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
constantCase: () => {
|
|
141
|
+
{
|
|
142
|
+
return constantCase;
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
capitalize: () => {
|
|
146
|
+
{
|
|
147
|
+
return capitalize;
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
capitalCase: () => {
|
|
151
|
+
{
|
|
152
|
+
return capitalCase;
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
camelCase: () => {
|
|
156
|
+
{
|
|
157
|
+
return camelCase;
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
addUncountableRule: () => {
|
|
161
|
+
{
|
|
162
|
+
return addUncountableRule2;
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
addSingularRule: () => {
|
|
166
|
+
{
|
|
167
|
+
return addSingularRule2;
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
addPluralRule: () => {
|
|
171
|
+
{
|
|
172
|
+
return addPluralRule2;
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
addIrregularRule: () => {
|
|
176
|
+
{
|
|
177
|
+
return addIrregularRule2;
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
Str: () => {
|
|
181
|
+
{
|
|
182
|
+
return Str;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// src/utils.ts
|
|
188
|
+
import slugify from "slugify";
|
|
189
|
+
function slash(str) {
|
|
190
|
+
return str.replace(/\\/g, "/");
|
|
191
|
+
}
|
|
192
|
+
function ensurePrefix(prefix, str) {
|
|
193
|
+
if (!str.startsWith(prefix))
|
|
194
|
+
return prefix + str;
|
|
195
|
+
return str;
|
|
196
|
+
}
|
|
197
|
+
function ensureSuffix(suffix, str) {
|
|
198
|
+
return str.endsWith(suffix) ? str : str + suffix;
|
|
199
|
+
}
|
|
200
|
+
function template(str, ...args) {
|
|
201
|
+
return str.replace(/{(\d+)}/g, (match, key) => {
|
|
202
|
+
const index = Number(key);
|
|
203
|
+
return Number.isNaN(index) ? match : args[index];
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
function truncate(str, length, end = "...") {
|
|
207
|
+
if (str.length <= length)
|
|
208
|
+
return str;
|
|
209
|
+
return str.slice(0, length - end.length) + end;
|
|
210
|
+
}
|
|
211
|
+
function random(size = 16, dict = urlAlphabet) {
|
|
212
|
+
let id = "";
|
|
213
|
+
let i = size;
|
|
214
|
+
const len = dict.length;
|
|
215
|
+
while (i--)
|
|
216
|
+
id += dict[Math.random() * len | 0];
|
|
217
|
+
return id;
|
|
218
|
+
}
|
|
219
|
+
function slug(str, options) {
|
|
220
|
+
if (options)
|
|
221
|
+
return slugify(str, options);
|
|
222
|
+
return slugify(str, {
|
|
223
|
+
lower: true,
|
|
224
|
+
strict: true
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
import {default as default2} from "detect-indent";
|
|
228
|
+
import {detectNewline} from "detect-newline";
|
|
229
|
+
var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
230
|
+
// src/case.ts
|
|
231
|
+
function capitalize(str) {
|
|
232
|
+
return str[0] ? str[0].toUpperCase() + str.slice(1).toLowerCase() : "";
|
|
233
|
+
}
|
|
234
|
+
import {
|
|
235
|
+
camelCase,
|
|
236
|
+
capitalCase,
|
|
237
|
+
constantCase,
|
|
238
|
+
dotCase,
|
|
239
|
+
noCase,
|
|
240
|
+
kebabCase,
|
|
241
|
+
kebabCase as kebabCase2,
|
|
242
|
+
pascalCase,
|
|
243
|
+
pathCase,
|
|
244
|
+
sentenceCase,
|
|
245
|
+
snakeCase,
|
|
246
|
+
split
|
|
247
|
+
} from "change-case";
|
|
248
|
+
import {titleCase} from "title-case";
|
|
249
|
+
// src/pluralize.ts
|
|
250
|
+
import * as pluralize from "pluralize";
|
|
251
|
+
var plural2 = (...args) => pluralize.plural(...args);
|
|
252
|
+
var singular2 = (...args) => pluralize.singular(...args);
|
|
253
|
+
var isPlural2 = (...args) => pluralize.isPlural(...args);
|
|
254
|
+
var isSingular2 = (...args) => pluralize.isSingular(...args);
|
|
255
|
+
var addPluralRule2 = (...args) => pluralize.addPluralRule(...args);
|
|
256
|
+
var addSingularRule2 = (...args) => pluralize.addSingularRule(...args);
|
|
257
|
+
var addIrregularRule2 = (...args) => pluralize.addIrregularRule(...args);
|
|
258
|
+
var addUncountableRule2 = (...args) => pluralize.addUncountableRule(...args);
|
|
259
|
+
// src/macro.ts
|
|
260
|
+
var Str = {
|
|
261
|
+
slash(str) {
|
|
262
|
+
return slash(str);
|
|
263
|
+
},
|
|
264
|
+
ensurePrefix(prefix, str) {
|
|
265
|
+
return ensurePrefix(prefix, str);
|
|
266
|
+
},
|
|
267
|
+
ensureSuffix(suffix, str) {
|
|
268
|
+
return ensureSuffix(suffix, str);
|
|
269
|
+
},
|
|
270
|
+
template(str, ...args) {
|
|
271
|
+
return template(str, ...args);
|
|
272
|
+
},
|
|
273
|
+
truncate(str, length, end = "...") {
|
|
274
|
+
return truncate(str, length, end);
|
|
275
|
+
},
|
|
276
|
+
random(length = 16) {
|
|
277
|
+
return random(length);
|
|
278
|
+
},
|
|
279
|
+
capitalize(str) {
|
|
280
|
+
return capitalize(str);
|
|
281
|
+
},
|
|
282
|
+
slug(str) {
|
|
283
|
+
return slug(str);
|
|
284
|
+
},
|
|
285
|
+
detectIndent(str) {
|
|
286
|
+
return default2(str);
|
|
287
|
+
},
|
|
288
|
+
detectNewline(str) {
|
|
289
|
+
return detectNewline(str);
|
|
290
|
+
},
|
|
291
|
+
camelCase(str) {
|
|
292
|
+
return camelCase(str);
|
|
293
|
+
},
|
|
294
|
+
capitalCase(str) {
|
|
295
|
+
return capitalCase(str);
|
|
296
|
+
},
|
|
297
|
+
constantCase(str) {
|
|
298
|
+
return constantCase(str);
|
|
299
|
+
},
|
|
300
|
+
dotCase(str) {
|
|
301
|
+
return dotCase(str);
|
|
302
|
+
},
|
|
303
|
+
noCase(str) {
|
|
304
|
+
return noCase(str);
|
|
305
|
+
},
|
|
306
|
+
paramCase(str) {
|
|
307
|
+
return kebabCase2(str);
|
|
308
|
+
},
|
|
309
|
+
pascalCase(str) {
|
|
310
|
+
return pascalCase(str);
|
|
311
|
+
},
|
|
312
|
+
pathCase(str) {
|
|
313
|
+
return pathCase(str);
|
|
314
|
+
},
|
|
315
|
+
sentenceCase(str) {
|
|
316
|
+
return sentenceCase(str);
|
|
317
|
+
},
|
|
318
|
+
snakeCase(str) {
|
|
319
|
+
return snakeCase(str);
|
|
320
|
+
},
|
|
321
|
+
titleCase(str) {
|
|
322
|
+
return titleCase(str);
|
|
323
|
+
},
|
|
324
|
+
kebabCase(str) {
|
|
325
|
+
return kebabCase(str);
|
|
326
|
+
},
|
|
327
|
+
plural(str) {
|
|
328
|
+
return plural2(str);
|
|
329
|
+
},
|
|
330
|
+
singular(str) {
|
|
331
|
+
return singular2(str);
|
|
332
|
+
},
|
|
333
|
+
isPlural(str) {
|
|
334
|
+
return isPlural2(str);
|
|
335
|
+
},
|
|
336
|
+
isSingular(str) {
|
|
337
|
+
return isSingular2(str);
|
|
338
|
+
},
|
|
339
|
+
addPluralRule(rule, repl) {
|
|
340
|
+
return addPluralRule2(rule, repl);
|
|
341
|
+
},
|
|
342
|
+
addSingularRule(rule, repl) {
|
|
343
|
+
return addSingularRule2(rule, repl);
|
|
344
|
+
},
|
|
345
|
+
addIrregularRule(single, plural3) {
|
|
346
|
+
return addIrregularRule2(single, plural3);
|
|
347
|
+
},
|
|
348
|
+
addUncountableRule(word) {
|
|
349
|
+
return addUncountableRule2(word);
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
var str = Str;
|
|
353
|
+
// src/helpers.ts
|
|
354
|
+
function toString(v) {
|
|
355
|
+
return Object.prototype.toString.call(v);
|
|
356
|
+
}
|
|
357
|
+
export {
|
|
358
|
+
truncate,
|
|
359
|
+
toString,
|
|
360
|
+
titleCase,
|
|
361
|
+
template,
|
|
362
|
+
exports_string as string,
|
|
363
|
+
str,
|
|
364
|
+
split,
|
|
365
|
+
snakeCase,
|
|
366
|
+
slug,
|
|
367
|
+
slash,
|
|
368
|
+
singular2 as singular,
|
|
369
|
+
sentenceCase,
|
|
370
|
+
random,
|
|
371
|
+
plural2 as plural,
|
|
372
|
+
pathCase,
|
|
373
|
+
pascalCase,
|
|
374
|
+
kebabCase2 as paramCase,
|
|
375
|
+
noCase,
|
|
376
|
+
kebabCase,
|
|
377
|
+
isSingular2 as isSingular,
|
|
378
|
+
isPlural2 as isPlural,
|
|
379
|
+
ensureSuffix,
|
|
380
|
+
ensurePrefix,
|
|
381
|
+
dotCase,
|
|
382
|
+
detectNewline,
|
|
383
|
+
default2 as detectIndent,
|
|
384
|
+
constantCase,
|
|
385
|
+
capitalize,
|
|
386
|
+
capitalCase,
|
|
387
|
+
camelCase,
|
|
388
|
+
addUncountableRule2 as addUncountableRule,
|
|
389
|
+
addSingularRule2 as addSingularRule,
|
|
390
|
+
addPluralRule2 as addPluralRule,
|
|
391
|
+
addIrregularRule2 as addIrregularRule,
|
|
392
|
+
Str
|
|
393
|
+
};
|
package/package.json
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/strings",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"packageManager": "pnpm@8.6.6",
|
|
4
|
+
"version": "0.58.19",
|
|
6
5
|
"description": "The Stacks string utilities.",
|
|
7
6
|
"author": "Chris Breuer",
|
|
8
7
|
"license": "MIT",
|
|
9
8
|
"funding": "https://github.com/sponsors/chrisbbreuer",
|
|
10
|
-
"homepage": "https://github.com/stacksjs/stacks/tree/main
|
|
9
|
+
"homepage": "https://github.com/stacksjs/stacks/tree/main/storage/framework/core/src/strings#readme",
|
|
11
10
|
"repository": {
|
|
12
11
|
"type": "git",
|
|
13
12
|
"url": "git+https://github.com/stacksjs/stacks.git",
|
|
14
|
-
"directory": "
|
|
13
|
+
"directory": "./storage/framework/core/src/strings"
|
|
15
14
|
},
|
|
16
15
|
"bugs": {
|
|
17
16
|
"url": "https://github.com/stacksjs/stacks/issues"
|
|
@@ -36,42 +35,47 @@
|
|
|
36
35
|
],
|
|
37
36
|
"exports": {
|
|
38
37
|
".": {
|
|
39
|
-
"
|
|
40
|
-
"import": "./dist/index.
|
|
38
|
+
"bun": "./src/index.ts",
|
|
39
|
+
"import": "./dist/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./*": {
|
|
42
|
+
"bun": "./src/*",
|
|
43
|
+
"import": "./dist/*"
|
|
41
44
|
}
|
|
42
45
|
},
|
|
43
|
-
"module": "dist/index.
|
|
46
|
+
"module": "dist/index.js",
|
|
44
47
|
"types": "dist/index.d.ts",
|
|
45
48
|
"contributors": [
|
|
46
|
-
"Chris Breuer <chris@
|
|
49
|
+
"Chris Breuer <chris@stacksjs.org>"
|
|
47
50
|
],
|
|
48
51
|
"files": [
|
|
49
|
-
"
|
|
50
|
-
"
|
|
52
|
+
"README.md",
|
|
53
|
+
"dist"
|
|
51
54
|
],
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "bun --bun build.ts",
|
|
57
|
+
"typecheck": "bun --bun tsc --noEmit",
|
|
58
|
+
"prepublishOnly": "bun --bun run build"
|
|
59
|
+
},
|
|
52
60
|
"peerDependencies": {
|
|
53
|
-
"@
|
|
54
|
-
"@types
|
|
55
|
-
|
|
61
|
+
"@stacksjs/alias": "workspace:*",
|
|
62
|
+
"@stacksjs/types": "workspace:*"
|
|
63
|
+
},
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"@stacksjs/alias": "workspace:*",
|
|
66
|
+
"@stacksjs/types": "workspace:*",
|
|
67
|
+
"change-case": "^5.4.1",
|
|
56
68
|
"detect-indent": "^7.0.1",
|
|
57
|
-
"detect-newline": "^4.0.
|
|
69
|
+
"detect-newline": "^4.0.1",
|
|
58
70
|
"macroable": "^7.0.2",
|
|
59
71
|
"pluralize": "^8.0.0",
|
|
60
72
|
"slugify": "^1.6.6",
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"@stacksjs/types": "0.57.4"
|
|
65
|
-
},
|
|
66
|
-
"dependencies": {
|
|
67
|
-
"macroable": "^7.0.2"
|
|
73
|
+
"string-ts": "^2.0.0",
|
|
74
|
+
"title-case": "^4.3.0",
|
|
75
|
+
"validator": "^13.11.0"
|
|
68
76
|
},
|
|
69
77
|
"devDependencies": {
|
|
70
|
-
"@stacksjs/development": "
|
|
71
|
-
|
|
72
|
-
"scripts": {
|
|
73
|
-
"build": "unbuild",
|
|
74
|
-
"dev": "unbuild --stub",
|
|
75
|
-
"typecheck": "tsc --noEmit"
|
|
78
|
+
"@stacksjs/development": "workspace:*",
|
|
79
|
+
"@types/validator": "^13.11.8"
|
|
76
80
|
}
|
|
77
|
-
}
|
|
81
|
+
}
|
package/LICENSE.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 Open Web Foundation
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
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, headerCase, noCase, paramCase, paramCase as kebabCase, pascalCase, pathCase, sentenceCase, snakeCase, } from 'change-case';
|
|
11
|
-
export { titleCase } from 'title-case';
|
package/dist/case.mjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export function capitalize(str) {
|
|
2
|
-
return str[0].toUpperCase() + str.slice(1).toLowerCase();
|
|
3
|
-
}
|
|
4
|
-
export {
|
|
5
|
-
camelCase,
|
|
6
|
-
capitalCase,
|
|
7
|
-
constantCase,
|
|
8
|
-
dotCase,
|
|
9
|
-
headerCase,
|
|
10
|
-
noCase,
|
|
11
|
-
paramCase,
|
|
12
|
-
paramCase as kebabCase,
|
|
13
|
-
pascalCase,
|
|
14
|
-
pathCase,
|
|
15
|
-
sentenceCase,
|
|
16
|
-
snakeCase
|
|
17
|
-
} from "change-case";
|
|
18
|
-
export { titleCase } from "title-case";
|
package/dist/index.d.ts
DELETED
package/dist/index.mjs
DELETED
package/dist/is.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { HashAlgorithm } from '@stacksjs/types';
|
|
2
|
-
export declare function isEmail(email: string): boolean;
|
|
3
|
-
export declare function isStrongPassword(password: string): boolean;
|
|
4
|
-
export declare function isAlphanumeric(username: string): boolean;
|
|
5
|
-
export declare function validateUsername(username: string): boolean;
|
|
6
|
-
export declare function isURL(url: string): boolean;
|
|
7
|
-
export declare function isMobilePhone(phoneNumber: string): boolean;
|
|
8
|
-
export declare function isAlpha(name: string): boolean;
|
|
9
|
-
export declare function isPostalCode(zipCode: string): boolean;
|
|
10
|
-
export declare function isNumeric(number: string): boolean;
|
|
11
|
-
export declare function isHexColor(color: string): boolean;
|
|
12
|
-
export declare function isHexadecimal(hex: string): boolean;
|
|
13
|
-
export declare function isBase64(base64: string): boolean;
|
|
14
|
-
export declare function isUUID(uuid: string): boolean;
|
|
15
|
-
export declare function isJSON(json: string): boolean;
|
|
16
|
-
export declare function isCreditCard(creditCard: string): boolean;
|
|
17
|
-
export declare function isISBN(isbn: string): boolean;
|
|
18
|
-
export declare function isIP(ip: string): boolean;
|
|
19
|
-
export declare function isIPRange(ip: string): boolean;
|
|
20
|
-
export declare function isMACAddress(macAddress: string): boolean;
|
|
21
|
-
export declare function isLatLong(latitude: string): boolean;
|
|
22
|
-
export declare function isLatitude(longitude: string): boolean;
|
|
23
|
-
export declare function isLongitude(longitude: string): boolean;
|
|
24
|
-
export declare function isCurrency(currency: string): boolean;
|
|
25
|
-
export declare function isDataURI(dataURI: string): boolean;
|
|
26
|
-
export declare function isMimeType(mimeType: string): boolean;
|
|
27
|
-
export declare function isJWT(jwt: string): boolean;
|
|
28
|
-
export declare function isAscii(ascii: string): boolean;
|
|
29
|
-
export declare function isBase32(base32: string): boolean;
|
|
30
|
-
export declare function isByteLength(byteLength: string): boolean;
|
|
31
|
-
export declare function isFQDN(fqdn: string): boolean;
|
|
32
|
-
export declare function isFullWidth(fullWidth: string): boolean;
|
|
33
|
-
export declare function isHalfWidth(halfWidth: string): boolean;
|
|
34
|
-
export declare function isHash(hash: string, algorithm: HashAlgorithm): boolean;
|
|
35
|
-
export declare function isHSL(hsl: string): boolean;
|
|
36
|
-
export declare function isIBAN(iban: string): boolean;
|
|
37
|
-
export declare function isIdentityCard(identityCard: string): boolean;
|
|
38
|
-
export declare function isISIN(isin: string): boolean;
|
|
39
|
-
export declare function isISO8601(iso8601: string): boolean;
|
|
40
|
-
export declare function isISRC(isrc: string): boolean;
|
|
41
|
-
export declare function isISSN(issn: string): boolean;
|
|
42
|
-
export declare function isISO31661Alpha2(iso31661Alpha2: string): boolean;
|
|
43
|
-
export declare function isISO31661Alpha3(iso31661Alpha3: string): boolean;
|
package/dist/is.mjs
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import v from "validator";
|
|
2
|
-
export function isEmail(email) {
|
|
3
|
-
return v.isEmail(email);
|
|
4
|
-
}
|
|
5
|
-
export function isStrongPassword(password) {
|
|
6
|
-
return v.isStrongPassword(password);
|
|
7
|
-
}
|
|
8
|
-
export function isAlphanumeric(username) {
|
|
9
|
-
return v.isAlphanumeric(username);
|
|
10
|
-
}
|
|
11
|
-
export function validateUsername(username) {
|
|
12
|
-
return isAlphanumeric(username);
|
|
13
|
-
}
|
|
14
|
-
export function isURL(url) {
|
|
15
|
-
return v.isURL(url);
|
|
16
|
-
}
|
|
17
|
-
export function isMobilePhone(phoneNumber) {
|
|
18
|
-
return v.isMobilePhone(phoneNumber);
|
|
19
|
-
}
|
|
20
|
-
export function isAlpha(name) {
|
|
21
|
-
return v.isAlpha(name);
|
|
22
|
-
}
|
|
23
|
-
export function isPostalCode(zipCode) {
|
|
24
|
-
return v.isPostalCode(zipCode, "any");
|
|
25
|
-
}
|
|
26
|
-
export function isNumeric(number) {
|
|
27
|
-
return v.isNumeric(number);
|
|
28
|
-
}
|
|
29
|
-
export function isHexColor(color) {
|
|
30
|
-
return v.isHexColor(color);
|
|
31
|
-
}
|
|
32
|
-
export function isHexadecimal(hex) {
|
|
33
|
-
return v.isHexadecimal(hex);
|
|
34
|
-
}
|
|
35
|
-
export function isBase64(base64) {
|
|
36
|
-
return v.isBase64(base64);
|
|
37
|
-
}
|
|
38
|
-
export function isUUID(uuid) {
|
|
39
|
-
return v.isUUID(uuid);
|
|
40
|
-
}
|
|
41
|
-
export function isJSON(json) {
|
|
42
|
-
return v.isJSON(json);
|
|
43
|
-
}
|
|
44
|
-
export function isCreditCard(creditCard) {
|
|
45
|
-
return v.isCreditCard(creditCard);
|
|
46
|
-
}
|
|
47
|
-
export function isISBN(isbn) {
|
|
48
|
-
return v.isISBN(isbn);
|
|
49
|
-
}
|
|
50
|
-
export function isIP(ip) {
|
|
51
|
-
return v.isIP(ip);
|
|
52
|
-
}
|
|
53
|
-
export function isIPRange(ip) {
|
|
54
|
-
return v.isIPRange(ip);
|
|
55
|
-
}
|
|
56
|
-
export function isMACAddress(macAddress) {
|
|
57
|
-
return v.isMACAddress(macAddress);
|
|
58
|
-
}
|
|
59
|
-
export function isLatLong(latitude) {
|
|
60
|
-
return v.isLatLong(latitude);
|
|
61
|
-
}
|
|
62
|
-
export function isLatitude(longitude) {
|
|
63
|
-
return v.isLatLong(longitude);
|
|
64
|
-
}
|
|
65
|
-
export function isLongitude(longitude) {
|
|
66
|
-
return v.isLatLong(longitude);
|
|
67
|
-
}
|
|
68
|
-
export function isCurrency(currency) {
|
|
69
|
-
return v.isCurrency(currency);
|
|
70
|
-
}
|
|
71
|
-
export function isDataURI(dataURI) {
|
|
72
|
-
return v.isDataURI(dataURI);
|
|
73
|
-
}
|
|
74
|
-
export function isMimeType(mimeType) {
|
|
75
|
-
return v.isMimeType(mimeType);
|
|
76
|
-
}
|
|
77
|
-
export function isJWT(jwt) {
|
|
78
|
-
return v.isJWT(jwt);
|
|
79
|
-
}
|
|
80
|
-
export function isAscii(ascii) {
|
|
81
|
-
return v.isAscii(ascii);
|
|
82
|
-
}
|
|
83
|
-
export function isBase32(base32) {
|
|
84
|
-
return v.isBase32(base32);
|
|
85
|
-
}
|
|
86
|
-
export function isByteLength(byteLength) {
|
|
87
|
-
return v.isByteLength(byteLength);
|
|
88
|
-
}
|
|
89
|
-
export function isFQDN(fqdn) {
|
|
90
|
-
return v.isFQDN(fqdn);
|
|
91
|
-
}
|
|
92
|
-
export function isFullWidth(fullWidth) {
|
|
93
|
-
return v.isFullWidth(fullWidth);
|
|
94
|
-
}
|
|
95
|
-
export function isHalfWidth(halfWidth) {
|
|
96
|
-
return v.isHalfWidth(halfWidth);
|
|
97
|
-
}
|
|
98
|
-
export function isHash(hash, algorithm) {
|
|
99
|
-
return v.isHash(hash, algorithm);
|
|
100
|
-
}
|
|
101
|
-
export function isHSL(hsl) {
|
|
102
|
-
return v.isHSL(hsl);
|
|
103
|
-
}
|
|
104
|
-
export function isIBAN(iban) {
|
|
105
|
-
return v.isIBAN(iban);
|
|
106
|
-
}
|
|
107
|
-
export function isIdentityCard(identityCard) {
|
|
108
|
-
return v.isIdentityCard(identityCard);
|
|
109
|
-
}
|
|
110
|
-
export function isISIN(isin) {
|
|
111
|
-
return v.isISIN(isin);
|
|
112
|
-
}
|
|
113
|
-
export function isISO8601(iso8601) {
|
|
114
|
-
return v.isISO8601(iso8601);
|
|
115
|
-
}
|
|
116
|
-
export function isISRC(isrc) {
|
|
117
|
-
return v.isISRC(isrc);
|
|
118
|
-
}
|
|
119
|
-
export function isISSN(issn) {
|
|
120
|
-
return v.isISSN(issn);
|
|
121
|
-
}
|
|
122
|
-
export function isISO31661Alpha2(iso31661Alpha2) {
|
|
123
|
-
return v.isISO31661Alpha2(iso31661Alpha2);
|
|
124
|
-
}
|
|
125
|
-
export function isISO31661Alpha3(iso31661Alpha3) {
|
|
126
|
-
return v.isISO31661Alpha3(iso31661Alpha3);
|
|
127
|
-
}
|
package/dist/macro.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Macroable } from 'macroable';
|
|
2
|
-
export declare class Str extends Macroable {
|
|
3
|
-
slash(str: string): string;
|
|
4
|
-
ensurePrefix(prefix: string, str: string): string;
|
|
5
|
-
ensureSuffix(suffix: string, str: string): string;
|
|
6
|
-
template(str: string, ...args: any[]): string;
|
|
7
|
-
/**
|
|
8
|
-
* Truncate a string
|
|
9
|
-
*/
|
|
10
|
-
truncate(str: string, length: number, end?: string): string;
|
|
11
|
-
random(length?: number): string;
|
|
12
|
-
capitalize(str: string): string;
|
|
13
|
-
slug(str: string): string;
|
|
14
|
-
detectIndent(str: string): import("detect-indent").Indent;
|
|
15
|
-
detectNewline(str: string): "\r\n" | "\n" | undefined;
|
|
16
|
-
camelCase(str: string): string;
|
|
17
|
-
capitalCase(str: string): string;
|
|
18
|
-
constantCase(str: string): string;
|
|
19
|
-
dotCase(str: string): string;
|
|
20
|
-
headerCase(str: string): string;
|
|
21
|
-
noCase(str: string): string;
|
|
22
|
-
paramCase(str: string): string;
|
|
23
|
-
pascalCase(str: string): string;
|
|
24
|
-
pathCase(str: string): string;
|
|
25
|
-
sentenceCase(str: string): string;
|
|
26
|
-
snakeCase(str: string): string;
|
|
27
|
-
titleCase(str: string): string;
|
|
28
|
-
kebabCase(str: string): string;
|
|
29
|
-
plural(str: string): any;
|
|
30
|
-
singular(str: string): any;
|
|
31
|
-
isPlural(str: string): any;
|
|
32
|
-
isSingular(str: string): any;
|
|
33
|
-
addPluralRule(rule: string | RegExp, repl: string): any;
|
|
34
|
-
addSingularRule(rule: string | RegExp, repl: string): any;
|
|
35
|
-
addIrregularRule(single: string, plural: string): any;
|
|
36
|
-
addUncountableRule(word: string | RegExp): any;
|
|
37
|
-
static macros: {};
|
|
38
|
-
static getters: {};
|
|
39
|
-
}
|
|
40
|
-
export declare const str: Str;
|
package/dist/macro.mjs
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { Macroable } from "macroable";
|
|
2
|
-
import * as c from "./case.mjs";
|
|
3
|
-
import * as p from "./pluralize.mjs";
|
|
4
|
-
import * as u from "./utils.mjs";
|
|
5
|
-
export class Str extends Macroable {
|
|
6
|
-
slash(str2) {
|
|
7
|
-
return u.slash(str2);
|
|
8
|
-
}
|
|
9
|
-
ensurePrefix(prefix, str2) {
|
|
10
|
-
return u.ensurePrefix(prefix, str2);
|
|
11
|
-
}
|
|
12
|
-
ensureSuffix(suffix, str2) {
|
|
13
|
-
return u.ensureSuffix(suffix, str2);
|
|
14
|
-
}
|
|
15
|
-
template(str2, ...args) {
|
|
16
|
-
return u.template(str2, ...args);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Truncate a string
|
|
20
|
-
*/
|
|
21
|
-
truncate(str2, length, end = "...") {
|
|
22
|
-
return u.truncate(str2, length, end);
|
|
23
|
-
}
|
|
24
|
-
random(length = 16) {
|
|
25
|
-
return u.randomStr(length);
|
|
26
|
-
}
|
|
27
|
-
capitalize(str2) {
|
|
28
|
-
return c.capitalize(str2);
|
|
29
|
-
}
|
|
30
|
-
slug(str2) {
|
|
31
|
-
return u.slug(str2);
|
|
32
|
-
}
|
|
33
|
-
detectIndent(str2) {
|
|
34
|
-
return u.detectIndent(str2);
|
|
35
|
-
}
|
|
36
|
-
detectNewline(str2) {
|
|
37
|
-
return u.detectNewline(str2);
|
|
38
|
-
}
|
|
39
|
-
camelCase(str2) {
|
|
40
|
-
return c.camelCase(str2);
|
|
41
|
-
}
|
|
42
|
-
capitalCase(str2) {
|
|
43
|
-
return c.capitalCase(str2);
|
|
44
|
-
}
|
|
45
|
-
constantCase(str2) {
|
|
46
|
-
return c.constantCase(str2);
|
|
47
|
-
}
|
|
48
|
-
dotCase(str2) {
|
|
49
|
-
return c.dotCase(str2);
|
|
50
|
-
}
|
|
51
|
-
headerCase(str2) {
|
|
52
|
-
return c.headerCase(str2);
|
|
53
|
-
}
|
|
54
|
-
noCase(str2) {
|
|
55
|
-
return c.noCase(str2);
|
|
56
|
-
}
|
|
57
|
-
paramCase(str2) {
|
|
58
|
-
return c.paramCase(str2);
|
|
59
|
-
}
|
|
60
|
-
pascalCase(str2) {
|
|
61
|
-
return c.pascalCase(str2);
|
|
62
|
-
}
|
|
63
|
-
pathCase(str2) {
|
|
64
|
-
return c.pathCase(str2);
|
|
65
|
-
}
|
|
66
|
-
sentenceCase(str2) {
|
|
67
|
-
return c.sentenceCase(str2);
|
|
68
|
-
}
|
|
69
|
-
snakeCase(str2) {
|
|
70
|
-
return c.snakeCase(str2);
|
|
71
|
-
}
|
|
72
|
-
titleCase(str2) {
|
|
73
|
-
return c.titleCase(str2);
|
|
74
|
-
}
|
|
75
|
-
kebabCase(str2) {
|
|
76
|
-
return c.kebabCase(str2);
|
|
77
|
-
}
|
|
78
|
-
plural(str2) {
|
|
79
|
-
return p.plural(str2);
|
|
80
|
-
}
|
|
81
|
-
singular(str2) {
|
|
82
|
-
return p.singular(str2);
|
|
83
|
-
}
|
|
84
|
-
isPlural(str2) {
|
|
85
|
-
return p.isPlural(str2);
|
|
86
|
-
}
|
|
87
|
-
isSingular(str2) {
|
|
88
|
-
return p.isSingular(str2);
|
|
89
|
-
}
|
|
90
|
-
addPluralRule(rule, repl) {
|
|
91
|
-
return p.addPluralRule(rule, repl);
|
|
92
|
-
}
|
|
93
|
-
addSingularRule(rule, repl) {
|
|
94
|
-
return p.addSingularRule(rule, repl);
|
|
95
|
-
}
|
|
96
|
-
addIrregularRule(single, plural) {
|
|
97
|
-
return p.addIrregularRule(single, plural);
|
|
98
|
-
}
|
|
99
|
-
addUncountableRule(word) {
|
|
100
|
-
return p.addUncountableRule(word);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
Str.macros = {};
|
|
104
|
-
Str.getters = {};
|
|
105
|
-
export const str = new Str();
|
package/dist/pluralize.d.ts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
declare const plural: any, singular: any, isPlural: any, isSingular: any, addPluralRule: any, addSingularRule: any, addIrregularRule: any, addUncountableRule: any;
|
|
2
|
-
export { plural, singular, isPlural, isSingular, addPluralRule, addSingularRule, addIrregularRule, addUncountableRule };
|
package/dist/pluralize.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import pluralize from "pluralize";
|
|
2
|
-
const { plural, singular, isPlural, isSingular, addPluralRule, addSingularRule, addIrregularRule, addUncountableRule } = pluralize;
|
|
3
|
-
export { plural, singular, isPlural, isSingular, addPluralRule, addSingularRule, addIrregularRule, addUncountableRule };
|
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 randomStr(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';
|
package/dist/utils.mjs
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import slugify from "slugify";
|
|
2
|
-
const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
3
|
-
export function slash(str) {
|
|
4
|
-
return str.replace(/\\/g, "/");
|
|
5
|
-
}
|
|
6
|
-
export function ensurePrefix(prefix, str) {
|
|
7
|
-
if (!str.startsWith(prefix))
|
|
8
|
-
return prefix + str;
|
|
9
|
-
return str;
|
|
10
|
-
}
|
|
11
|
-
export function ensureSuffix(suffix, str) {
|
|
12
|
-
if (!str.endsWith(suffix))
|
|
13
|
-
return str + suffix;
|
|
14
|
-
return str;
|
|
15
|
-
}
|
|
16
|
-
export function template(str, ...args) {
|
|
17
|
-
return str.replace(/{(\d+)}/g, (match, key) => {
|
|
18
|
-
const index = Number(key);
|
|
19
|
-
if (Number.isNaN(index))
|
|
20
|
-
return match;
|
|
21
|
-
return args[index];
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
export function truncate(str, length, end = "...") {
|
|
25
|
-
if (str.length <= length)
|
|
26
|
-
return str;
|
|
27
|
-
return str.slice(0, length - end.length) + end;
|
|
28
|
-
}
|
|
29
|
-
export function randomStr(size = 16, dict = urlAlphabet) {
|
|
30
|
-
let id = "";
|
|
31
|
-
let i = size;
|
|
32
|
-
const len = dict.length;
|
|
33
|
-
while (i--)
|
|
34
|
-
id += dict[Math.random() * len | 0];
|
|
35
|
-
return id;
|
|
36
|
-
}
|
|
37
|
-
export function slug(str, options) {
|
|
38
|
-
if (options)
|
|
39
|
-
return slugify(str, options);
|
|
40
|
-
return slugify(str, {
|
|
41
|
-
lower: true,
|
|
42
|
-
strict: true
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
export { default as detectIndent } from "detect-indent";
|
|
46
|
-
export { detectNewline } from "detect-newline";
|