complete-common 2.7.1 → 2.8.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.
|
@@ -28,6 +28,8 @@ export declare function hasDiacritic(string: string): boolean;
|
|
|
28
28
|
export declare function hasEmoji(string: string): boolean;
|
|
29
29
|
/** From: https://stackoverflow.com/questions/1731190/check-if-a-string-has-white-space */
|
|
30
30
|
export declare function hasWhitespace(string: string): boolean;
|
|
31
|
+
/** Helper function to determine if a string only contains ASCII characters. */
|
|
32
|
+
export declare function isASCII(str: string): boolean;
|
|
31
33
|
/**
|
|
32
34
|
* From:
|
|
33
35
|
* https://stackoverflow.com/questions/8334606/check-if-first-letter-of-word-is-a-capital-letter
|
|
@@ -28,6 +28,8 @@ export declare function hasDiacritic(string: string): boolean;
|
|
|
28
28
|
export declare function hasEmoji(string: string): boolean;
|
|
29
29
|
/** From: https://stackoverflow.com/questions/1731190/check-if-a-string-has-white-space */
|
|
30
30
|
export declare function hasWhitespace(string: string): boolean;
|
|
31
|
+
/** Helper function to determine if a string only contains ASCII characters. */
|
|
32
|
+
export declare function isASCII(str: string): boolean;
|
|
31
33
|
/**
|
|
32
34
|
* From:
|
|
33
35
|
* https://stackoverflow.com/questions/8334606/check-if-first-letter-of-word-is-a-capital-letter
|
|
@@ -28,6 +28,8 @@ export declare function hasDiacritic(string: string): boolean;
|
|
|
28
28
|
export declare function hasEmoji(string: string): boolean;
|
|
29
29
|
/** From: https://stackoverflow.com/questions/1731190/check-if-a-string-has-white-space */
|
|
30
30
|
export declare function hasWhitespace(string: string): boolean;
|
|
31
|
+
/** Helper function to determine if a string only contains ASCII characters. */
|
|
32
|
+
export declare function isASCII(str: string): boolean;
|
|
31
33
|
/**
|
|
32
34
|
* From:
|
|
33
35
|
* https://stackoverflow.com/questions/8334606/check-if-first-letter-of-word-is-a-capital-letter
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/functions/string.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/functions/string.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAyBH,kEAAkE;AAClE,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAU5D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAO3D;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAqBlE;AAED,6EAA6E;AAC7E,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAOpD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED,0FAA0F;AAC1F,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAErD;AAED,+EAA+E;AAC/E,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE5C;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED,+FAA+F;AAC/F,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAGhE;AAED,+FAA+F;AAC/F,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED,wEAAwE;AACxE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAO3D;AAED,yEAAyE;AACzE,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAG5D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAiBtD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,GACtD;IACE,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAC;IAErB,wDAAwD;IACxD,YAAY,EAAE,MAAM,CAAC;IAErB,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAC;CACtB,GACD,SAAS,CAwBZ;AAGD;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,MAAM,CAuBR;AAED,gGAAgG;AAChG,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAIzE;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED,yEAAyE;AACzE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,UAAQ,GACd,MAAM,CAWR;AAED,gGAAgG;AAChG,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAOjE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAMxE"}
|
package/dist/index.cjs
CHANGED
|
@@ -399,6 +399,7 @@ function repeat(num, func) {
|
|
|
399
399
|
function todo(...args) {
|
|
400
400
|
}
|
|
401
401
|
|
|
402
|
+
const ASCII_REGEX = /^[\u0000-\u007F]*$/;
|
|
402
403
|
const DIACRITIC_REGEX = /\p{Diacritic}/u;
|
|
403
404
|
const EMOJI_REGEX = /(\p{Extended_Pictographic}|[#*0-9]\uFE0F?\u20E3)/u;
|
|
404
405
|
const FIRST_LETTER_CAPITALIZED_REGEX = /^\p{Lu}/u;
|
|
@@ -445,6 +446,9 @@ function hasEmoji(string) {
|
|
|
445
446
|
function hasWhitespace(string) {
|
|
446
447
|
return WHITESPACE_REGEX.test(string);
|
|
447
448
|
}
|
|
449
|
+
function isASCII(str) {
|
|
450
|
+
return ASCII_REGEX.test(str);
|
|
451
|
+
}
|
|
448
452
|
function isFirstLetterCapitalized(string) {
|
|
449
453
|
return FIRST_LETTER_CAPITALIZED_REGEX.test(string);
|
|
450
454
|
}
|
|
@@ -614,6 +618,7 @@ exports.iRange = iRange;
|
|
|
614
618
|
exports.includes = includes;
|
|
615
619
|
exports.includesAny = includesAny;
|
|
616
620
|
exports.interfaceSatisfiesEnum = interfaceSatisfiesEnum;
|
|
621
|
+
exports.isASCII = isASCII;
|
|
617
622
|
exports.isArray = isArray;
|
|
618
623
|
exports.isArrayBoolean = isArrayBoolean;
|
|
619
624
|
exports.isArrayNumber = isArrayNumber;
|
package/dist/index.mjs
CHANGED
|
@@ -397,6 +397,7 @@ function repeat(num, func) {
|
|
|
397
397
|
function todo(...args) {
|
|
398
398
|
}
|
|
399
399
|
|
|
400
|
+
const ASCII_REGEX = /^[\u0000-\u007F]*$/;
|
|
400
401
|
const DIACRITIC_REGEX = /\p{Diacritic}/u;
|
|
401
402
|
const EMOJI_REGEX = /(\p{Extended_Pictographic}|[#*0-9]\uFE0F?\u20E3)/u;
|
|
402
403
|
const FIRST_LETTER_CAPITALIZED_REGEX = /^\p{Lu}/u;
|
|
@@ -443,6 +444,9 @@ function hasEmoji(string) {
|
|
|
443
444
|
function hasWhitespace(string) {
|
|
444
445
|
return WHITESPACE_REGEX.test(string);
|
|
445
446
|
}
|
|
447
|
+
function isASCII(str) {
|
|
448
|
+
return ASCII_REGEX.test(str);
|
|
449
|
+
}
|
|
446
450
|
function isFirstLetterCapitalized(string) {
|
|
447
451
|
return FIRST_LETTER_CAPITALIZED_REGEX.test(string);
|
|
448
452
|
}
|
|
@@ -566,4 +570,4 @@ function* tupleKeys(tuple) {
|
|
|
566
570
|
|
|
567
571
|
const ReadonlyMap = Map;
|
|
568
572
|
|
|
569
|
-
export { HOUR_IN_MILLISECONDS, MINUTE_IN_MILLISECONDS, ReadonlyMap, ReadonlySet, SECOND_IN_MILLISECONDS, addSetsToSet, arrayCopyTwoDimensional, arrayEquals, arrayRemove, arrayRemoveAllInPlace, arrayRemoveInPlace, assertArray, assertArrayBoolean, assertArrayNumber, assertArrayString, assertBoolean, assertDefined, assertEnumValue, assertIs, assertNotNull, assertNumber, assertObject, assertString, capitalizeFirstLetter, clamp, combineSets, copySet, eRange, emptyArray, escapeHTMLCharacters, filterMap, getElapsedSeconds, getEnumEntries, getEnumKeys, getEnumValues, getNumConsecutiveDiacritics, getRandomArrayElement, getRandomArrayIndex, getRandomInt, hasDiacritic, hasEmoji, hasWhitespace, iRange, includes, includesAny, interfaceSatisfiesEnum, isArray, isArrayBoolean, isArrayNumber, isArrayString, isEnumValue, isFirstLetterCapitalized, isKebabCase, isKeyOf, isLowerCase, isObject, isSemanticVersion, isUpperCase, kebabCaseToCamelCase, kebabCaseToPascalCase, mapFilter, mapFind, newArray, noop, normalizeString, objectFilter, objectKeysToSet, objectToMap, objectToReverseMap, objectValuesToSet, parseFloatSafe, parseIntSafe, parseSemanticVersion, removeLinesBetweenMarkers, removeLinesMatching, removeNonPrintableCharacters, removeWhitespace, repeat, setAdd, setHas, sortCaseInsensitive, sumArray, todo, trimPrefix, trimSuffix, truncateString, tupleEntries, tupleKeys };
|
|
573
|
+
export { HOUR_IN_MILLISECONDS, MINUTE_IN_MILLISECONDS, ReadonlyMap, ReadonlySet, SECOND_IN_MILLISECONDS, addSetsToSet, arrayCopyTwoDimensional, arrayEquals, arrayRemove, arrayRemoveAllInPlace, arrayRemoveInPlace, assertArray, assertArrayBoolean, assertArrayNumber, assertArrayString, assertBoolean, assertDefined, assertEnumValue, assertIs, assertNotNull, assertNumber, assertObject, assertString, capitalizeFirstLetter, clamp, combineSets, copySet, eRange, emptyArray, escapeHTMLCharacters, filterMap, getElapsedSeconds, getEnumEntries, getEnumKeys, getEnumValues, getNumConsecutiveDiacritics, getRandomArrayElement, getRandomArrayIndex, getRandomInt, hasDiacritic, hasEmoji, hasWhitespace, iRange, includes, includesAny, interfaceSatisfiesEnum, isASCII, isArray, isArrayBoolean, isArrayNumber, isArrayString, isEnumValue, isFirstLetterCapitalized, isKebabCase, isKeyOf, isLowerCase, isObject, isSemanticVersion, isUpperCase, kebabCaseToCamelCase, kebabCaseToPascalCase, mapFilter, mapFind, newArray, noop, normalizeString, objectFilter, objectKeysToSet, objectToMap, objectToReverseMap, objectValuesToSet, parseFloatSafe, parseIntSafe, parseSemanticVersion, removeLinesBetweenMarkers, removeLinesMatching, removeNonPrintableCharacters, removeWhitespace, repeat, setAdd, setHas, sortCaseInsensitive, sumArray, todo, trimPrefix, trimSuffix, truncateString, tupleEntries, tupleKeys };
|
package/package.json
CHANGED
package/src/functions/string.ts
CHANGED
|
@@ -9,6 +9,9 @@ import { parseIntSafe } from "./utils.js";
|
|
|
9
9
|
// When regular expressions are located at the root instead of inside the function, the functions
|
|
10
10
|
// are tested to perform 11% faster.
|
|
11
11
|
|
|
12
|
+
// eslint-disable-next-line no-control-regex
|
|
13
|
+
const ASCII_REGEX = /^[\u0000-\u007F]*$/;
|
|
14
|
+
|
|
12
15
|
const DIACRITIC_REGEX = /\p{Diacritic}/u;
|
|
13
16
|
|
|
14
17
|
/**
|
|
@@ -104,6 +107,11 @@ export function hasWhitespace(string: string): boolean {
|
|
|
104
107
|
return WHITESPACE_REGEX.test(string);
|
|
105
108
|
}
|
|
106
109
|
|
|
110
|
+
/** Helper function to determine if a string only contains ASCII characters. */
|
|
111
|
+
export function isASCII(str: string): boolean {
|
|
112
|
+
return ASCII_REGEX.test(str);
|
|
113
|
+
}
|
|
114
|
+
|
|
107
115
|
/**
|
|
108
116
|
* From:
|
|
109
117
|
* https://stackoverflow.com/questions/8334606/check-if-first-letter-of-word-is-a-capital-letter
|