cafe-utility 4.11.0 → 4.12.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/index.d.ts +6 -0
- package/index.js +21 -4
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -144,6 +144,9 @@ declare function randomize(string: string): string;
|
|
|
144
144
|
declare function shrinkTrim(string: string): string;
|
|
145
145
|
declare function capitalize(string: string): string;
|
|
146
146
|
declare function decapitalize(string: string): string;
|
|
147
|
+
declare function isLetter(character: string): boolean;
|
|
148
|
+
declare function isDigit(character: string): boolean;
|
|
149
|
+
declare function isLetterOrDigit(character: string): boolean;
|
|
147
150
|
declare function csvEscape(string: string): string;
|
|
148
151
|
declare function findWeightedPair(string: string, start?: number, opening?: string, closing?: string): number;
|
|
149
152
|
interface BlockExtractionOptions {
|
|
@@ -497,6 +500,9 @@ export declare const Strings: {
|
|
|
497
500
|
joinHumanly: typeof joinHumanly;
|
|
498
501
|
findWeightedPair: typeof findWeightedPair;
|
|
499
502
|
extractBlock: typeof extractBlock;
|
|
503
|
+
isLetter: typeof isLetter;
|
|
504
|
+
isDigit: typeof isDigit;
|
|
505
|
+
isLetterOrDigit: typeof isLetterOrDigit;
|
|
500
506
|
};
|
|
501
507
|
export declare const Assertions: {
|
|
502
508
|
asEqual: typeof asEqual;
|
package/index.js
CHANGED
|
@@ -927,6 +927,20 @@ function decapitalize(string) {
|
|
|
927
927
|
return string.charAt(0).toLowerCase() + string.slice(1)
|
|
928
928
|
}
|
|
929
929
|
|
|
930
|
+
function isLetter(character) {
|
|
931
|
+
const code = character.charCodeAt(0)
|
|
932
|
+
return (code >= 65 && code <= 90) || (code >= 97 && code <= 122)
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
function isDigit(character) {
|
|
936
|
+
const code = character.charCodeAt(0)
|
|
937
|
+
return code >= 48 && code <= 57
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
function isLetterOrDigit(character) {
|
|
941
|
+
return isLetter(character) || isDigit(character)
|
|
942
|
+
}
|
|
943
|
+
|
|
930
944
|
function csvEscape(string) {
|
|
931
945
|
return string.match(/"|,/) ? `"${string.replace(/"/g, '""')}"` : string
|
|
932
946
|
}
|
|
@@ -934,12 +948,12 @@ function csvEscape(string) {
|
|
|
934
948
|
function findWeightedPair(string, start = 0, opening = '{', closing = '}') {
|
|
935
949
|
let weight = 1
|
|
936
950
|
for (let i = start; i < string.length; i++) {
|
|
937
|
-
if (string[i] ===
|
|
938
|
-
weight++
|
|
939
|
-
} else if (string[i] === closing) {
|
|
951
|
+
if (string[i] === closing) {
|
|
940
952
|
if (--weight === 0) {
|
|
941
953
|
return i
|
|
942
954
|
}
|
|
955
|
+
} else if (string[i] === opening) {
|
|
956
|
+
weight++
|
|
943
957
|
}
|
|
944
958
|
}
|
|
945
959
|
return -1
|
|
@@ -1959,7 +1973,10 @@ exports.Strings = {
|
|
|
1959
1973
|
slugToCamel,
|
|
1960
1974
|
joinHumanly,
|
|
1961
1975
|
findWeightedPair,
|
|
1962
|
-
extractBlock
|
|
1976
|
+
extractBlock,
|
|
1977
|
+
isLetter,
|
|
1978
|
+
isDigit,
|
|
1979
|
+
isLetterOrDigit
|
|
1963
1980
|
}
|
|
1964
1981
|
|
|
1965
1982
|
exports.Assertions = {
|