@zinaid/str 0.0.6 → 0.0.8
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/ascii/index.d.ts +16 -0
- package/dist/ascii/index.d.ts.map +1 -1
- package/dist/ascii/index.js +43 -4
- package/dist/base64/index.d.ts +16 -0
- package/dist/base64/index.d.ts.map +1 -1
- package/dist/base64/index.js +52 -51
- package/dist/convertcase/index.d.ts +10 -0
- package/dist/convertcase/index.d.ts.map +1 -1
- package/dist/index.js +113 -112
- package/dist/markdown/index.d.ts +23 -0
- package/dist/markdown/index.d.ts.map +1 -1
- package/dist/pluralizer/index.d.ts +61 -0
- package/dist/pluralizer/index.d.ts.map +1 -1
- package/dist/pluralizer/index.js +36 -27
- package/dist/replacer/index.d.ts +14 -14
- package/dist/{str.d.ts → str/index.d.ts} +297 -66
- package/dist/str/index.d.ts.map +1 -0
- package/dist/str/index.js +939 -0
- package/dist/stringable/index.d.ts +398 -1
- package/dist/stringable/index.d.ts.map +1 -1
- package/dist/stringable/index.js +400 -13
- package/dist/transliterate/index.d.ts +5 -0
- package/dist/transliterate/index.d.ts.map +1 -1
- package/dist/trimmer/index.d.ts +21 -0
- package/dist/trimmer/index.d.ts.map +1 -1
- package/dist/ulid/index.d.ts +38 -0
- package/dist/ulid/index.d.ts.map +1 -1
- package/dist/ulid/index.js +37 -29
- package/dist/uuid/index.d.ts +34 -0
- package/dist/uuid/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/str.d.ts.map +0 -1
- package/dist/str.js +0 -993
|
@@ -2,9 +2,44 @@ import { default as pluralize } from 'pluralize';
|
|
|
2
2
|
export interface PluralizerRules {
|
|
3
3
|
uncountable: string[];
|
|
4
4
|
}
|
|
5
|
+
/**
|
|
6
|
+
* Pluralize the last word of an English, studly caps case string.
|
|
7
|
+
*
|
|
8
|
+
* @param value - The studly caps case string to pluralize
|
|
9
|
+
* @param count - The count to determine pluralization (default: 2)
|
|
10
|
+
* @returns The pluralized studly caps case string
|
|
11
|
+
*
|
|
12
|
+
* @requires {@link https://www.npmjs.com/package/pluralize pluralize package}
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
*
|
|
16
|
+
* pluralStudly("These are the school", 4); -> "These are the schools"
|
|
17
|
+
*/
|
|
18
|
+
export declare function pluralStudly(value: string, count?: number): string;
|
|
19
|
+
/**
|
|
20
|
+
* Pluralize the last word of an English, Pascal caps case string.
|
|
21
|
+
*
|
|
22
|
+
* @param value - The Pascal caps case string to pluralize
|
|
23
|
+
* @param count - The count to determine pluralization (default: 2)
|
|
24
|
+
* @returns The pluralized Pascal caps case string
|
|
25
|
+
*
|
|
26
|
+
* @requires {@link https://www.npmjs.com/package/pluralize pluralize package}
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
*
|
|
30
|
+
* pluralPascal("These are the school", 4); -> "These are the schools"
|
|
31
|
+
*/
|
|
32
|
+
export declare function pluralPascal(value: string, count?: number): string;
|
|
5
33
|
/**
|
|
6
34
|
* Get the plural form of an English word.
|
|
7
35
|
*
|
|
36
|
+
* @param value - The word to pluralize.
|
|
37
|
+
* @param count - The count to determine pluralization (default: 2)
|
|
38
|
+
* @param prependCount - Whether to prepend the count to the result (default: false)
|
|
39
|
+
* @returns The pluralized word, optionally with the count prepended.
|
|
40
|
+
*
|
|
41
|
+
* @requires {@link https://www.npmjs.com/package/pluralize pluralize package}
|
|
42
|
+
*
|
|
8
43
|
* @example
|
|
9
44
|
*
|
|
10
45
|
* plural("child"); -> "children"
|
|
@@ -14,26 +49,52 @@ export interface PluralizerRules {
|
|
|
14
49
|
export declare function plural(value: string, count?: number, prependCount?: boolean): string;
|
|
15
50
|
/**
|
|
16
51
|
* Get the singular form of an English word.
|
|
52
|
+
*
|
|
53
|
+
* @param value - The word to singularize.
|
|
54
|
+
* @returns The singular form of the word.
|
|
55
|
+
*
|
|
56
|
+
* @requires {@link https://www.npmjs.com/package/pluralize pluralize package}
|
|
17
57
|
*/
|
|
18
58
|
export declare function singular(value: string): string;
|
|
19
59
|
/**
|
|
20
60
|
* Determine if the given value is uncountable.
|
|
61
|
+
*
|
|
62
|
+
* @param value - The word to check.
|
|
63
|
+
* @returns True if the word is uncountable, false otherwise.
|
|
64
|
+
*
|
|
65
|
+
* @requires {@link https://www.npmjs.com/package/pluralize pluralize package}
|
|
21
66
|
*/
|
|
22
67
|
export declare function uncountable(value: string): boolean;
|
|
23
68
|
/**
|
|
24
69
|
* Determine if the given value is plural.
|
|
70
|
+
*
|
|
71
|
+
* @param value - The word to check.
|
|
72
|
+
* @returns True if the word is plural, false otherwise.
|
|
73
|
+
*
|
|
74
|
+
* @requires {@link https://www.npmjs.com/package/pluralize pluralize package}
|
|
25
75
|
*/
|
|
26
76
|
export declare function isPlural(value?: string): boolean;
|
|
27
77
|
/**
|
|
28
78
|
* Determine if the given value is singular.
|
|
79
|
+
*
|
|
80
|
+
* @param value - The word to check.
|
|
81
|
+
* @returns True if the word is singular, false otherwise.
|
|
82
|
+
*
|
|
83
|
+
* @requires {@link https://www.npmjs.com/package/pluralize pluralize package}
|
|
29
84
|
*/
|
|
30
85
|
export declare function isSingular(value?: string): boolean;
|
|
31
86
|
/**
|
|
32
87
|
* Attempt to match the case on two strings
|
|
88
|
+
*
|
|
89
|
+
* @param value - The string to adjust.
|
|
90
|
+
* @param comparison - The string to match the case against.
|
|
91
|
+
* @returns The adjusted string with matched case.
|
|
33
92
|
*/
|
|
34
93
|
export declare function matchCase(value: string, comparison: string): string;
|
|
35
94
|
/**
|
|
36
95
|
* Get the pluralize instance
|
|
96
|
+
*
|
|
97
|
+
* @returns The pluralize instance.
|
|
37
98
|
*/
|
|
38
99
|
export declare function inflector(): typeof pluralize;
|
|
39
100
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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
|
|
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;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,MAAU,GAAG,MAAM,CAKrE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,MAAU,GAAG,MAAM,CAErE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,MAAM,CAClB,KAAK,EAAE,MAAM,EACb,KAAK,GAAE,MAAU,EACjB,YAAY,GAAE,OAAe,GAC9B,MAAM,CAKR;AAqBD;;;;;;;GAOG;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,7 +1,7 @@
|
|
|
1
|
-
import { format as
|
|
2
|
-
import { isUndefined as
|
|
3
|
-
import
|
|
4
|
-
let
|
|
1
|
+
import { format as s } from "@zinaid/num";
|
|
2
|
+
import { isUndefined as l } from "@zinaid/utils";
|
|
3
|
+
import f from "pluralize";
|
|
4
|
+
let t;
|
|
5
5
|
const o = {
|
|
6
6
|
uncountable: [
|
|
7
7
|
"audio",
|
|
@@ -49,42 +49,51 @@ const o = {
|
|
|
49
49
|
"wheat"
|
|
50
50
|
]
|
|
51
51
|
};
|
|
52
|
-
function
|
|
53
|
-
|
|
52
|
+
function c(e, n = 2) {
|
|
53
|
+
const r = e.split(/(?=[A-Z])/), a = String(r.pop());
|
|
54
|
+
return r.join("") + p(a, n);
|
|
54
55
|
}
|
|
55
|
-
function
|
|
56
|
-
|
|
56
|
+
function h(e, n = 2) {
|
|
57
|
+
return c(e, n);
|
|
58
|
+
}
|
|
59
|
+
function p(e, n = 2, r = !1) {
|
|
60
|
+
return (r ? s(n) + " " : "") + d(e, n);
|
|
61
|
+
}
|
|
62
|
+
function d(e, n) {
|
|
63
|
+
if (Math.abs(n) === 1 || m(e))
|
|
57
64
|
return e;
|
|
58
|
-
const
|
|
59
|
-
return u(
|
|
65
|
+
const r = i().plural(e);
|
|
66
|
+
return u(r, e);
|
|
60
67
|
}
|
|
61
|
-
function
|
|
62
|
-
const n =
|
|
68
|
+
function C(e) {
|
|
69
|
+
const n = i().singular(e);
|
|
63
70
|
return u(n, e);
|
|
64
71
|
}
|
|
65
|
-
function
|
|
72
|
+
function m(e) {
|
|
66
73
|
return o.uncountable.includes(e.toLowerCase());
|
|
67
74
|
}
|
|
68
|
-
function
|
|
69
|
-
return
|
|
75
|
+
function U(e = "") {
|
|
76
|
+
return i().isPlural(e);
|
|
70
77
|
}
|
|
71
|
-
function
|
|
72
|
-
return
|
|
78
|
+
function k(e = "") {
|
|
79
|
+
return i().isSingular(e);
|
|
73
80
|
}
|
|
74
81
|
function u(e, n) {
|
|
75
82
|
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;
|
|
76
83
|
}
|
|
77
|
-
function
|
|
78
|
-
return
|
|
79
|
-
(e) =>
|
|
80
|
-
)),
|
|
84
|
+
function i() {
|
|
85
|
+
return l(t) && (t = f, o.uncountable.forEach(
|
|
86
|
+
(e) => t.addUncountableRule(e)
|
|
87
|
+
)), t;
|
|
81
88
|
}
|
|
82
89
|
export {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
90
|
+
i as inflector,
|
|
91
|
+
U as isPlural,
|
|
92
|
+
k as isSingular,
|
|
86
93
|
u as matchCase,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
c as
|
|
94
|
+
p as plural,
|
|
95
|
+
h as pluralPascal,
|
|
96
|
+
c as pluralStudly,
|
|
97
|
+
C as singular,
|
|
98
|
+
m as uncountable
|
|
90
99
|
};
|
package/dist/replacer/index.d.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns the portion of the string specified by the start and length parameters.
|
|
3
3
|
*
|
|
4
|
-
* @param string
|
|
5
|
-
* @param start
|
|
6
|
-
* @param length
|
|
7
|
-
* @returns
|
|
4
|
+
* @param string - The input string.
|
|
5
|
+
* @param start - The starting position. If negative, it starts that many characters from the end of the string.
|
|
6
|
+
* @param length - The number of characters to return. If omitted or null, returns all characters from start to the end of the string. If negative, omits that many characters from the end.
|
|
7
|
+
* @returns The extracted substring.
|
|
8
8
|
*/
|
|
9
9
|
export declare function substr(string: string, start: number, length?: number | null): string;
|
|
10
10
|
/**
|
|
11
11
|
* Returns the number of substring occurrences.
|
|
12
12
|
*
|
|
13
|
-
* @param haystack
|
|
14
|
-
* @param needle
|
|
15
|
-
* @param offset
|
|
16
|
-
* @param length
|
|
17
|
-
* @returns
|
|
13
|
+
* @param haystack - The string to search within.
|
|
14
|
+
* @param needle - The substring to count.
|
|
15
|
+
* @param offset - The starting position for the search. If negative, it starts that many characters from the end of the string.
|
|
16
|
+
* @param length - The length of the segment to search within. If omitted or null, searches to the end of the string. If negative, omits that many characters from the end.
|
|
17
|
+
* @returns The number of occurrences of the substring within the specified segment.
|
|
18
18
|
*/
|
|
19
19
|
export declare function substrCount(haystack: string, needle: string, offset?: number, length?: number | null): number;
|
|
20
20
|
/**
|
|
21
21
|
* Replace text within a portion of a string.
|
|
22
22
|
* Properly handles multibyte characters.
|
|
23
23
|
*
|
|
24
|
-
* @param value
|
|
25
|
-
* @param replace
|
|
26
|
-
* @param offset
|
|
27
|
-
* @param length
|
|
28
|
-
* @returns
|
|
24
|
+
* @param value - The original string.
|
|
25
|
+
* @param replace - The replacement string or an array of replacement strings.
|
|
26
|
+
* @param offset - The starting position for the replacement. If negative, it starts that many characters from the end of the string.
|
|
27
|
+
* @param length - The number of characters to replace. If omitted or null, replaces all characters from offset to the end of the string. If negative, omits that many characters from the end.
|
|
28
|
+
* @returns The modified string or an array of modified strings if multiple replacements are provided.
|
|
29
29
|
*/
|
|
30
30
|
export declare function substrReplace(value: string, replace: string | string[], offset?: number | number[], length?: number | number[] | null): string | string[];
|
|
31
31
|
//# sourceMappingURL=index.d.ts.map
|