@tolki/str 1.1.0 → 1.2.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/README.md +45 -6
- package/dist/index.js +125 -124
- package/dist/pluralizer/index.d.ts +13 -1
- package/dist/pluralizer/index.d.ts.map +1 -1
- package/dist/pluralizer/index.js +44 -39
- package/dist/str.d.ts.map +1 -1
- package/dist/str.js +4 -3
- package/dist/stringable/index.d.ts +9 -2
- package/dist/stringable/index.d.ts.map +1 -1
- package/dist/stringable/index.js +99 -90
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -62,7 +62,7 @@ However, if you are working on a backend project where bundle size is not a conc
|
|
|
62
62
|
|
|
63
63
|
These are the string utilities that can be used independently as single functions.
|
|
64
64
|
|
|
65
|
-
[after](#after) [afterLast](#afterlast) [apa](#apa) [ascii](#ascii) [before](#before) [beforeLast](#beforelast) [between](#between) [betweenFirst](#betweenfirst) [camel](#camel) [charAt](#charat) [chopEnd](#chopend) [chopStart](#chopstart) [contains](#contains) [containsAll](#containsall) [doesntContain](#doesntcontain) [deduplicate](#deduplicate) [doesntEndWith](#doesntendwith) [doesntStartWith](#doesntstartwith) [endsWith](#endswith) [excerpt](#excerpt) [finish](#finish) [fromBase64](#frombase64) [headline](#headline) [initials](#initials) [inlineMarkdown](#inlinemarkdown) [is](#is) [isAscii](#isascii) [isJson](#isjson) [isUrl](#isurl) [isUlid](#isulid) [isUuid](#isuuid) [kebab](#kebab) [lcfirst](#lcfirst) [length](#length) [limit](#limit) [lower](#lower) [markdown](#markdown) [mask](#mask) [match](#match) [matchAll](#matchall) [isMatch](#ismatch) [numbers](#numbers) [padBoth](#padboth) [padLeft](#padleft) [padRight](#padright) [pascal](#pascal) [pluralPascal](#pluralpascal) [password](#password) [plural](#plural) [pluralStudly](#pluralstudly) [position](#position) [random](#random) [remove](#remove) [repeat](#repeat) [replace](#replace) [replaceArray](#replacearray) [replaceFirst](#replacefirst) [replaceLast](#replacelast) [replaceMatches](#replacematches) [replaceStart](#replacestart) [replaceEnd](#replaceend) [reverse](#reverse) [singular](#singular) [slug](#slug) [snake](#snake) [squish](#squish) [start](#start) [startsWith](#startswith) [stripTags](#striptags) [studly](#studly) [substr](#substr) [substrCount](#substrcount) [substrReplace](#substrreplace) [swap](#swap) [take](#take) [title](#title) [toBase64](#tobase64) [transliterate](#transliterate) [trim](#trim) [ltrim](#ltrim) [rtrim](#rtrim) [ucfirst](#ucfirst) [ucsplit](#ucsplit) [ucwords](#ucwords) [upper](#upper) [ulid](#ulid) [unwrap](#unwrap) [uuid](#uuid) [uuid7](#uuid7) [wordCount](#wordcount) [wordWrap](#wordwrap) [words](#words) [wrap](#wrap) [str](#str) [of](#of)
|
|
65
|
+
[after](#after) [afterLast](#afterlast) [apa](#apa) [ascii](#ascii) [before](#before) [beforeLast](#beforelast) [between](#between) [betweenFirst](#betweenfirst) [camel](#camel) [charAt](#charat) [chopEnd](#chopend) [chopStart](#chopstart) [contains](#contains) [containsAll](#containsall) [counted](#counted) [doesntContain](#doesntcontain) [deduplicate](#deduplicate) [doesntEndWith](#doesntendwith) [doesntStartWith](#doesntstartwith) [endsWith](#endswith) [excerpt](#excerpt) [finish](#finish) [fromBase64](#frombase64) [headline](#headline) [initials](#initials) [inlineMarkdown](#inlinemarkdown) [is](#is) [isAscii](#isascii) [isJson](#isjson) [isUrl](#isurl) [isUlid](#isulid) [isUuid](#isuuid) [kebab](#kebab) [lcfirst](#lcfirst) [length](#length) [limit](#limit) [lower](#lower) [markdown](#markdown) [mask](#mask) [match](#match) [matchAll](#matchall) [isMatch](#ismatch) [numbers](#numbers) [padBoth](#padboth) [padLeft](#padleft) [padRight](#padright) [pascal](#pascal) [pluralPascal](#pluralpascal) [password](#password) [plural](#plural) [pluralStudly](#pluralstudly) [position](#position) [random](#random) [remove](#remove) [repeat](#repeat) [replace](#replace) [replaceArray](#replacearray) [replaceFirst](#replacefirst) [replaceLast](#replacelast) [replaceMatches](#replacematches) [replaceStart](#replacestart) [replaceEnd](#replaceend) [reverse](#reverse) [singular](#singular) [slug](#slug) [snake](#snake) [squish](#squish) [start](#start) [startsWith](#startswith) [stripTags](#striptags) [studly](#studly) [substr](#substr) [substrCount](#substrcount) [substrReplace](#substrreplace) [swap](#swap) [take](#take) [title](#title) [toBase64](#tobase64) [transliterate](#transliterate) [trim](#trim) [ltrim](#ltrim) [rtrim](#rtrim) [ucfirst](#ucfirst) [ucsplit](#ucsplit) [ucwords](#ucwords) [upper](#upper) [ulid](#ulid) [unwrap](#unwrap) [uuid](#uuid) [uuid7](#uuid7) [wordCount](#wordcount) [wordWrap](#wordwrap) [words](#words) [wrap](#wrap) [str](#str) [of](#of)
|
|
66
66
|
|
|
67
67
|
### String Utilities Details
|
|
68
68
|
|
|
@@ -286,6 +286,32 @@ const result = containsAll("This is my name", ["MY", "NAME"], true);
|
|
|
286
286
|
// result is true
|
|
287
287
|
```
|
|
288
288
|
|
|
289
|
+
#### counted
|
|
290
|
+
|
|
291
|
+
Get the plural form of an English word with the count prepended.
|
|
292
|
+
|
|
293
|
+
```javascript
|
|
294
|
+
import { counted } from "@tolki/str";
|
|
295
|
+
|
|
296
|
+
const result = counted("order", 1);
|
|
297
|
+
|
|
298
|
+
// result is "1 order"
|
|
299
|
+
|
|
300
|
+
const result2 = counted("order", 1000);
|
|
301
|
+
|
|
302
|
+
// result2 is "1,000 orders"
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
You may also pass an array as the count, in which case its length is used:
|
|
306
|
+
|
|
307
|
+
```javascript
|
|
308
|
+
import { counted } from "@tolki/str";
|
|
309
|
+
|
|
310
|
+
const result = counted("order", ["a", "b"]);
|
|
311
|
+
|
|
312
|
+
// result is "2 orders"
|
|
313
|
+
```
|
|
314
|
+
|
|
289
315
|
#### doesntContain
|
|
290
316
|
|
|
291
317
|
Determine if a given string doesn't contain a given substring.
|
|
@@ -437,7 +463,7 @@ import { excerpt } from "@tolki/str";
|
|
|
437
463
|
|
|
438
464
|
const result = excerpt("This is my name", "my", { radius: 3 });
|
|
439
465
|
|
|
440
|
-
// result is "...
|
|
466
|
+
// result is "...is my na..."
|
|
441
467
|
```
|
|
442
468
|
|
|
443
469
|
The radius option, which defaults to 100, allows you to define the number of characters that should appear on each side of the truncated string.
|
|
@@ -584,7 +610,7 @@ const result = is("*.jpg", "photo.JPG", true);
|
|
|
584
610
|
|
|
585
611
|
#### isAscii
|
|
586
612
|
|
|
587
|
-
Determine if a given string is 7
|
|
613
|
+
Determine if a given string is 7-bit ASCII.
|
|
588
614
|
|
|
589
615
|
```javascript
|
|
590
616
|
import { isAscii } from "@tolki/str";
|
|
@@ -834,7 +860,7 @@ const result = mask("taylor@example.com", "*", 3);
|
|
|
834
860
|
// result is "tay***************"
|
|
835
861
|
```
|
|
836
862
|
|
|
837
|
-
If needed, you provide a negative value for the third argument, which instructs the function to begin masking from the end of the string. A fourth argument may also provided to specify the number of masked characters.
|
|
863
|
+
If needed, you may provide a negative value for the third argument, which instructs the function to begin masking from the end of the string. A fourth argument may also be provided to specify the number of masked characters.
|
|
838
864
|
|
|
839
865
|
```javascript
|
|
840
866
|
import { mask } from "@tolki/str";
|
|
@@ -986,6 +1012,8 @@ const result = pluralPascal("HelloWorld");
|
|
|
986
1012
|
|
|
987
1013
|
#### password
|
|
988
1014
|
|
|
1015
|
+
`password`, `random`, `ulid`, `uuid`, and `uuid7` (along with their `createXUsing`/`createXNormally` testing helpers) generate a new value on every call, so a live playground would just show a different, unverifiable result each time you touch it — there's no live example for these.
|
|
1016
|
+
|
|
989
1017
|
Generate a random, secure password.
|
|
990
1018
|
|
|
991
1019
|
```javascript
|
|
@@ -1317,7 +1345,7 @@ const result2 = singular("children");
|
|
|
1317
1345
|
|
|
1318
1346
|
#### slug
|
|
1319
1347
|
|
|
1320
|
-
Generate a URL
|
|
1348
|
+
Generate a URL-friendly "slug" from a given string.
|
|
1321
1349
|
|
|
1322
1350
|
```javascript
|
|
1323
1351
|
import { slug } from "@tolki/str";
|
|
@@ -1475,7 +1503,7 @@ const result = swap(
|
|
|
1475
1503
|
"Tacos are great!",
|
|
1476
1504
|
);
|
|
1477
1505
|
|
|
1478
|
-
// result is "Burritos are fantastic"
|
|
1506
|
+
// result is "Burritos are fantastic!"
|
|
1479
1507
|
```
|
|
1480
1508
|
|
|
1481
1509
|
#### take
|
|
@@ -1518,6 +1546,10 @@ const result = toBase64("Laravel");
|
|
|
1518
1546
|
// result is "TGFyYXZlbA=="
|
|
1519
1547
|
```
|
|
1520
1548
|
|
|
1549
|
+
#### trans
|
|
1550
|
+
|
|
1551
|
+
This function is purposely not implemented. Laravel's `Str::trans` resolves translation keys through the framework's localization system, which has no equivalent in this library. Use a JavaScript i18n library (such as [i18next](https://www.i18next.com/) or [FormatJS](https://formatjs.github.io/)) to translate strings instead.
|
|
1552
|
+
|
|
1521
1553
|
#### transliterate
|
|
1522
1554
|
|
|
1523
1555
|
Transliterate a string to its closest ASCII representation.
|
|
@@ -1773,6 +1805,11 @@ dog.
|
|
|
1773
1805
|
*/
|
|
1774
1806
|
```
|
|
1775
1807
|
|
|
1808
|
+
' },
|
|
1809
|
+
{ name: 'cutLongWords', type: 'boolean', default: false },
|
|
1810
|
+
]"
|
|
1811
|
+
/>
|
|
1812
|
+
|
|
1776
1813
|
#### words
|
|
1777
1814
|
|
|
1778
1815
|
Limit the number of words in a string.
|
|
@@ -1807,6 +1844,8 @@ Using the `str` or `of` functions is discouraged for frontend projects because i
|
|
|
1807
1844
|
|
|
1808
1845
|
For frontend projects, it is recommended to use the individual string functions instead for better tree-shaking and smaller bundle sizes.
|
|
1809
1846
|
|
|
1847
|
+
Also unlike the standalone functions on this page, `str`/`of` return a `Stringable` class instance rather than a plain value, so there's no live playground for them here — try the fluent methods it exposes (like `.append()` or `.snake()`) directly in your own code instead.
|
|
1848
|
+
|
|
1810
1849
|
Get a new Stringable object from the given string.
|
|
1811
1850
|
|
|
1812
1851
|
```javascript
|
package/dist/index.js
CHANGED
|
@@ -1,140 +1,141 @@
|
|
|
1
1
|
import { ascii as t, slug as a } from "./ascii/index.js";
|
|
2
2
|
import { bytesToBase64 as i, fromBase64 as o, toBase64 as n } from "./base64/index.js";
|
|
3
|
-
import { CaseTypes as c, convertCase as
|
|
3
|
+
import { CaseTypes as c, convertCase as d, title as p, upper as u } from "./convertcase/index.js";
|
|
4
4
|
import { inlineMarkdown as f, markDownRenderer as h, markdown as g } from "./markdown/index.js";
|
|
5
|
-
import {
|
|
6
|
-
import { randomInt as
|
|
7
|
-
import { substr as
|
|
8
|
-
import { after as
|
|
9
|
-
import { Stringable as
|
|
10
|
-
import { transliterate as
|
|
11
|
-
import { ltrim as
|
|
12
|
-
import { createUlidsNormally as
|
|
13
|
-
import { createUuidsNormally as
|
|
5
|
+
import { counted as U, inflector as w, isPlural as x, isSingular as b, matchCase as y, plural as C, pluralPascal as k, pluralStudly as R, singular as z, uncountable as A } from "./pluralizer/index.js";
|
|
6
|
+
import { randomInt as q, randomString as B } from "./random/index.js";
|
|
7
|
+
import { substr as v, substrCount as E, substrReplace as F } from "./replacer/index.js";
|
|
8
|
+
import { after as N, afterLast as P, apa as T, before as D, beforeLast as I, between as J, betweenFirst as O, camel as j, camelCacheSize as G, charAt as H, chopEnd as K, chopStart as Q, contains as V, containsAll as X, createRandomStringsNormally as Y, createRandomStringsUsing as Z, createRandomStringsUsingSequence as _, deduplicate as $, doesntContain as ee, doesntEndWith as re, doesntStartWith as te, endsWith as ae, excerpt as se, finish as ie, flushCache as oe, headline as ne, initials as le, is as ce, isAscii as de, isJson as pe, isMatch as ue, isUrl as me, kebab as fe, lcfirst as he, length as ge, limit as Se, lower as Ue, makePad as we, mask as xe, match as be, matchAll as ye, numbers as Ce, padBoth as ke, padLeft as Re, padRight as ze, pascal as Ae, password as We, position as qe, random as Be, remove as Le, repeat as ve, replace as Ee, replaceArray as Fe, replaceEnd as Me, replaceFirst as Ne, replaceLast as Pe, replaceMatches as Te, replaceStart as De, resetFactoryState as Ie, reverse as Je, snake as Oe, snakeCacheSize as je, squish as Ge, start as He, startsWith as Ke, stripTags as Qe, studly as Ve, studlyCacheSize as Xe, swap as Ye, take as Ze, toStringOr as _e, ucfirst as $e, ucsplit as er, ucwords as rr, unwrap as tr, wordCount as ar, wordWrap as sr, words as ir, wrap as or } from "./str.js";
|
|
9
|
+
import { Stringable as lr, of as cr, str as dr } from "./stringable/index.js";
|
|
10
|
+
import { transliterate as ur } from "./transliterate/index.js";
|
|
11
|
+
import { ltrim as fr, rtrim as hr, trim as gr } from "./trimmer/index.js";
|
|
12
|
+
import { createUlidsNormally as Ur, createUlidsUsing as wr, createUlidsUsingSequence as xr, freezeUlids as br, isUlid as yr, ulid as Cr } from "./ulid/index.js";
|
|
13
|
+
import { createUuidsNormally as Rr, createUuidsUsing as zr, createUuidsUsingSequence as Ar, freezeUuids as Wr, isUuid as qr, uuid as Br, uuid7 as Lr } from "./uuid/index.js";
|
|
14
14
|
export {
|
|
15
15
|
c as CaseTypes,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
lr as Stringable,
|
|
17
|
+
N as after,
|
|
18
|
+
P as afterLast,
|
|
19
|
+
T as apa,
|
|
20
20
|
t as ascii,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
D as before,
|
|
22
|
+
I as beforeLast,
|
|
23
|
+
J as between,
|
|
24
|
+
O as betweenFirst,
|
|
25
25
|
i as bytesToBase64,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
Y as
|
|
36
|
-
Z as
|
|
37
|
-
|
|
38
|
-
Ur as
|
|
39
|
-
wr as
|
|
40
|
-
|
|
41
|
-
Rr as
|
|
42
|
-
zr as
|
|
43
|
-
|
|
44
|
-
$ as
|
|
45
|
-
ee as
|
|
46
|
-
re as
|
|
47
|
-
te as
|
|
48
|
-
ae as
|
|
49
|
-
se as
|
|
50
|
-
ie as
|
|
51
|
-
|
|
52
|
-
|
|
26
|
+
j as camel,
|
|
27
|
+
G as camelCacheSize,
|
|
28
|
+
H as charAt,
|
|
29
|
+
K as chopEnd,
|
|
30
|
+
Q as chopStart,
|
|
31
|
+
V as contains,
|
|
32
|
+
X as containsAll,
|
|
33
|
+
d as convertCase,
|
|
34
|
+
U as counted,
|
|
35
|
+
Y as createRandomStringsNormally,
|
|
36
|
+
Z as createRandomStringsUsing,
|
|
37
|
+
_ as createRandomStringsUsingSequence,
|
|
38
|
+
Ur as createUlidsNormally,
|
|
39
|
+
wr as createUlidsUsing,
|
|
40
|
+
xr as createUlidsUsingSequence,
|
|
41
|
+
Rr as createUuidsNormally,
|
|
42
|
+
zr as createUuidsUsing,
|
|
43
|
+
Ar as createUuidsUsingSequence,
|
|
44
|
+
$ as deduplicate,
|
|
45
|
+
ee as doesntContain,
|
|
46
|
+
re as doesntEndWith,
|
|
47
|
+
te as doesntStartWith,
|
|
48
|
+
ae as endsWith,
|
|
49
|
+
se as excerpt,
|
|
50
|
+
ie as finish,
|
|
51
|
+
oe as flushCache,
|
|
52
|
+
br as freezeUlids,
|
|
53
|
+
Wr as freezeUuids,
|
|
53
54
|
o as fromBase64,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
ne as headline,
|
|
56
|
+
w as inflector,
|
|
57
|
+
le as initials,
|
|
57
58
|
f as inlineMarkdown,
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
ce as is,
|
|
60
|
+
de as isAscii,
|
|
60
61
|
pe as isJson,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
62
|
+
ue as isMatch,
|
|
63
|
+
x as isPlural,
|
|
64
|
+
b as isSingular,
|
|
65
|
+
yr as isUlid,
|
|
66
|
+
me as isUrl,
|
|
67
|
+
qr as isUuid,
|
|
68
|
+
fe as kebab,
|
|
69
|
+
he as lcfirst,
|
|
70
|
+
ge as length,
|
|
71
|
+
Se as limit,
|
|
72
|
+
Ue as lower,
|
|
73
|
+
fr as ltrim,
|
|
74
|
+
we as makePad,
|
|
74
75
|
h as markDownRenderer,
|
|
75
76
|
g as markdown,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
77
|
+
xe as mask,
|
|
78
|
+
be as match,
|
|
79
|
+
ye as matchAll,
|
|
80
|
+
y as matchCase,
|
|
81
|
+
Ce as numbers,
|
|
82
|
+
cr as of,
|
|
83
|
+
ke as padBoth,
|
|
84
|
+
Re as padLeft,
|
|
85
|
+
ze as padRight,
|
|
86
|
+
Ae as pascal,
|
|
87
|
+
We as password,
|
|
88
|
+
C as plural,
|
|
89
|
+
k as pluralPascal,
|
|
90
|
+
R as pluralStudly,
|
|
91
|
+
qe as position,
|
|
92
|
+
Be as random,
|
|
93
|
+
q as randomInt,
|
|
94
|
+
B as randomString,
|
|
95
|
+
Le as remove,
|
|
96
|
+
ve as repeat,
|
|
97
|
+
Ee as replace,
|
|
98
|
+
Fe as replaceArray,
|
|
99
|
+
Me as replaceEnd,
|
|
100
|
+
Ne as replaceFirst,
|
|
101
|
+
Pe as replaceLast,
|
|
102
|
+
Te as replaceMatches,
|
|
103
|
+
De as replaceStart,
|
|
104
|
+
Ie as resetFactoryState,
|
|
105
|
+
Je as reverse,
|
|
106
|
+
hr as rtrim,
|
|
107
|
+
z as singular,
|
|
107
108
|
a as slug,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
109
|
+
Oe as snake,
|
|
110
|
+
je as snakeCacheSize,
|
|
111
|
+
Ge as squish,
|
|
112
|
+
He as start,
|
|
113
|
+
Ke as startsWith,
|
|
114
|
+
dr as str,
|
|
115
|
+
Qe as stripTags,
|
|
116
|
+
Ve as studly,
|
|
117
|
+
Xe as studlyCacheSize,
|
|
118
|
+
v as substr,
|
|
119
|
+
E as substrCount,
|
|
120
|
+
F as substrReplace,
|
|
121
|
+
Ye as swap,
|
|
122
|
+
Ze as take,
|
|
123
|
+
p as title,
|
|
123
124
|
n as toBase64,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
125
|
+
_e as toStringOr,
|
|
126
|
+
ur as transliterate,
|
|
127
|
+
gr as trim,
|
|
128
|
+
$e as ucfirst,
|
|
129
|
+
er as ucsplit,
|
|
130
|
+
rr as ucwords,
|
|
131
|
+
Cr as ulid,
|
|
132
|
+
A as uncountable,
|
|
133
|
+
tr as unwrap,
|
|
133
134
|
u as upper,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
135
|
+
Br as uuid,
|
|
136
|
+
Lr as uuid7,
|
|
137
|
+
ar as wordCount,
|
|
138
|
+
sr as wordWrap,
|
|
139
|
+
ir as words,
|
|
140
|
+
or as wrap
|
|
140
141
|
};
|
|
@@ -38,7 +38,19 @@ export declare function pluralPascal(value: string, count?: number): string;
|
|
|
38
38
|
*
|
|
39
39
|
* @requires {@link https://www.npmjs.com/package/pluralize pluralize package}
|
|
40
40
|
*/
|
|
41
|
-
export declare function plural(value: string, count?: number, prependCount?: boolean): string;
|
|
41
|
+
export declare function plural(value: string, count?: number | unknown[], prependCount?: boolean): string;
|
|
42
|
+
/**
|
|
43
|
+
* Get the plural form of an English word with the count prepended.
|
|
44
|
+
*
|
|
45
|
+
* @param value - The word to pluralize.
|
|
46
|
+
* @param count - The count to determine pluralization. Arrays are counted by length.
|
|
47
|
+
* @returns The pluralized word with the formatted count prepended.
|
|
48
|
+
*
|
|
49
|
+
* @see https://tolki.abe.dev/strings/string-utilities-list.html#counted
|
|
50
|
+
*
|
|
51
|
+
* @requires {@link https://www.npmjs.com/package/pluralize pluralize package}
|
|
52
|
+
*/
|
|
53
|
+
export declare function counted(value: string, count: number | unknown[]): string;
|
|
42
54
|
/**
|
|
43
55
|
* Get the singular form of an English word.
|
|
44
56
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pluralizer/index.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,MAAM,WAAW,eAAe;IAC5B,WAAW,EAAE,MAAM,EAAE,CAAC;CACzB;AAoDD;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,MAAU,GAAG,MAAM,CAKrE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,MAAU,GAAG,MAAM,CAErE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAClB,KAAK,EAAE,MAAM,EACb,KAAK,GAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pluralizer/index.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,MAAM,WAAW,eAAe;IAC5B,WAAW,EAAE,MAAM,EAAE,CAAC;CACzB;AAoDD;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,MAAU,GAAG,MAAM,CAKrE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,MAAU,GAAG,MAAM,CAErE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAClB,KAAK,EAAE,MAAM,EACb,KAAK,GAAE,MAAM,GAAG,OAAO,EAAM,EAC7B,YAAY,GAAE,OAAe,GAC9B,MAAM,CAOR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,EAAE,GAAG,MAAM,CAExE;AAqBD;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAI9C;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,KAAK,GAAE,MAAW,GAAG,OAAO,CAEpD;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,GAAE,MAAW,GAAG,OAAO,CAEtD;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAiBnE;AAED;;;;GAIG;AACH,wBAAgB,SAAS,IAAI,OAAO,SAAS,CAU5C"}
|
package/dist/pluralizer/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { format as
|
|
2
|
-
import { isUndefined as
|
|
3
|
-
import
|
|
4
|
-
let
|
|
5
|
-
const
|
|
1
|
+
import { format as l } from "@tolki/num";
|
|
2
|
+
import { isUndefined as f, isNumber as c } from "@tolki/utils";
|
|
3
|
+
import p from "pluralize";
|
|
4
|
+
let i;
|
|
5
|
+
const u = {
|
|
6
6
|
uncountable: [
|
|
7
7
|
"audio",
|
|
8
8
|
"bison",
|
|
@@ -49,51 +49,56 @@ const o = {
|
|
|
49
49
|
"wheat"
|
|
50
50
|
]
|
|
51
51
|
};
|
|
52
|
-
function
|
|
53
|
-
const
|
|
54
|
-
return
|
|
52
|
+
function d(e, n = 2) {
|
|
53
|
+
const t = e.split(/(?=[A-Z])/), r = String(t.pop());
|
|
54
|
+
return t.join("") + a(r, n);
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
return
|
|
56
|
+
function C(e, n = 2) {
|
|
57
|
+
return d(e, n);
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
|
|
59
|
+
function a(e, n = 2, t = !1) {
|
|
60
|
+
const r = c(n) ? n : n.length;
|
|
61
|
+
return (t ? l(r) + " " : "") + m(e, r);
|
|
61
62
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
63
|
+
function U(e, n) {
|
|
64
|
+
return a(e, n, !0);
|
|
65
|
+
}
|
|
66
|
+
function m(e, n) {
|
|
67
|
+
if (Math.abs(n) === 1 || g(e))
|
|
64
68
|
return e;
|
|
65
|
-
const
|
|
66
|
-
return
|
|
69
|
+
const t = o().plural(e);
|
|
70
|
+
return s(t, e);
|
|
67
71
|
}
|
|
68
|
-
function
|
|
69
|
-
const n =
|
|
70
|
-
return
|
|
72
|
+
function k(e) {
|
|
73
|
+
const n = o().singular(e);
|
|
74
|
+
return s(n, e);
|
|
71
75
|
}
|
|
72
|
-
function
|
|
73
|
-
return
|
|
76
|
+
function g(e) {
|
|
77
|
+
return u.uncountable.includes(e.toLowerCase());
|
|
74
78
|
}
|
|
75
|
-
function
|
|
76
|
-
return
|
|
79
|
+
function S(e = "") {
|
|
80
|
+
return o().isPlural(e);
|
|
77
81
|
}
|
|
78
|
-
function
|
|
79
|
-
return
|
|
82
|
+
function j(e = "") {
|
|
83
|
+
return o().isSingular(e);
|
|
80
84
|
}
|
|
81
|
-
function
|
|
85
|
+
function s(e, n) {
|
|
82
86
|
return n.toLowerCase() === n ? e.toLowerCase() : n.toUpperCase() === n ? e.toUpperCase() : n[0] && n[0].toUpperCase() + n.slice(1) === n ? (e[0] ?? "").toUpperCase() + e.slice(1) : e;
|
|
83
87
|
}
|
|
84
|
-
function
|
|
85
|
-
return
|
|
86
|
-
(e) =>
|
|
87
|
-
)),
|
|
88
|
+
function o() {
|
|
89
|
+
return f(i) && (i = p, u.uncountable.forEach(
|
|
90
|
+
(e) => i.addUncountableRule(e)
|
|
91
|
+
)), i;
|
|
88
92
|
}
|
|
89
93
|
export {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
U as counted,
|
|
95
|
+
o as inflector,
|
|
96
|
+
S as isPlural,
|
|
97
|
+
j as isSingular,
|
|
98
|
+
s as matchCase,
|
|
99
|
+
a as plural,
|
|
100
|
+
C as pluralPascal,
|
|
101
|
+
d as pluralStudly,
|
|
102
|
+
k as singular,
|
|
103
|
+
g as uncountable
|
|
99
104
|
};
|
package/dist/str.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"str.d.ts","sourceRoot":"","sources":["../src/str.ts"],"names":[],"mappings":"AA6BA;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAatE;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAY1E;AAED;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,C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;;;;;;GAQG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAIjC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAIxC"}
|
package/dist/str.js
CHANGED
|
@@ -84,10 +84,11 @@ function Lt(t, e = "", n = {}) {
|
|
|
84
84
|
return A !== h && (A = A + s), w + a + A;
|
|
85
85
|
}
|
|
86
86
|
function Et(t, e, n = !1) {
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
let r = !1;
|
|
88
|
+
for (const s of e)
|
|
89
|
+
if (r = !0, !H(t, s, n))
|
|
89
90
|
return !1;
|
|
90
|
-
return
|
|
91
|
+
return r;
|
|
91
92
|
}
|
|
92
93
|
function Rt(t, e, n = !1) {
|
|
93
94
|
return !H(t, e, n);
|
|
@@ -150,6 +150,13 @@ export declare class Stringable {
|
|
|
150
150
|
* @returns The converted string as a new Stringable instance.
|
|
151
151
|
*/
|
|
152
152
|
convertCase(mode: ConvertCaseMode): Stringable;
|
|
153
|
+
/**
|
|
154
|
+
* Get the plural form of an English word with the count prepended.
|
|
155
|
+
*
|
|
156
|
+
* @param count - The count to determine pluralization. Arrays are counted by length.
|
|
157
|
+
* @returns The pluralized string with the formatted count prepended, as a new Stringable instance.
|
|
158
|
+
*/
|
|
159
|
+
counted(count: number | unknown[]): Stringable;
|
|
153
160
|
/**
|
|
154
161
|
* Replace consecutive instances of a given character with a single character.
|
|
155
162
|
*
|
|
@@ -383,11 +390,11 @@ export declare class Stringable {
|
|
|
383
390
|
/**
|
|
384
391
|
* Get the plural form of an English word.
|
|
385
392
|
*
|
|
386
|
-
* @param count - The count to determine singular or plural form. Defaults to 2.
|
|
393
|
+
* @param count - The count to determine singular or plural form. Arrays are counted by length. Defaults to 2.
|
|
387
394
|
* @param prependCount - Whether to prepend the count to the result. Defaults to false.
|
|
388
395
|
* @returns The pluralized string as a new Stringable instance.
|
|
389
396
|
*/
|
|
390
|
-
plural(count?: number, prependCount?: boolean): Stringable;
|
|
397
|
+
plural(count?: number | unknown[], prependCount?: boolean): Stringable;
|
|
391
398
|
/**
|
|
392
399
|
* Pluralize the last word of an English, studly caps case string.
|
|
393
400
|
*
|