@stacksjs/strings 0.70.25 → 0.70.26
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/index.js +10 -10
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -943,7 +943,7 @@ function isAlpha(str2) {
|
|
|
943
943
|
return /^[a-zA-Z]+$/.test(str2);
|
|
944
944
|
}
|
|
945
945
|
function isPostalCode(zipCode) {
|
|
946
|
-
const usZip = /^\d{5}(
|
|
946
|
+
const usZip = /^\d{5}(?:-\d{4})?$/;
|
|
947
947
|
const ukPostcode = /^[A-Z]{1,2}\d{1,2}[A-Z]?\s?\d[A-Z]{2}$/i;
|
|
948
948
|
const canadaPostcode = /^[A-Z]\d[A-Z]\s?\d[A-Z]\d$/i;
|
|
949
949
|
const generic = /^[a-zA-Z0-9]{3,10}$/;
|
|
@@ -953,7 +953,7 @@ function isNumeric(str2) {
|
|
|
953
953
|
return /^\d+$/.test(str2);
|
|
954
954
|
}
|
|
955
955
|
function isHexColor(color) {
|
|
956
|
-
return /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(color);
|
|
956
|
+
return /^#(?:[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(color);
|
|
957
957
|
}
|
|
958
958
|
function isHexadecimal(hex) {
|
|
959
959
|
return /^[A-Fa-f0-9]+$/.test(hex);
|
|
@@ -1028,10 +1028,10 @@ function isISBN(isbn) {
|
|
|
1028
1028
|
return false;
|
|
1029
1029
|
}
|
|
1030
1030
|
function isIP(ip) {
|
|
1031
|
-
const ipv4Regex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
|
|
1031
|
+
const ipv4Regex = /^(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
|
|
1032
1032
|
if (ipv4Regex.test(ip))
|
|
1033
1033
|
return true;
|
|
1034
|
-
const ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(
|
|
1034
|
+
const ipv6Regex = /^(?:(?:[0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,7}:|(?:[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,5}(?::[0-9a-fA-F]{1,4}){1,2}|(?:[0-9a-fA-F]{1,4}:){1,4}(?::[0-9a-fA-F]{1,4}){1,3}|(?:[0-9a-fA-F]{1,4}:){1,3}(?::[0-9a-fA-F]{1,4}){1,4}|(?:[0-9a-fA-F]{1,4}:){1,2}(?::[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:(?:(?::[0-9a-fA-F]{1,4}){1,6})|:(?:(?::[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(?::[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(?:ffff(?::0{1,4}){0,1}:){0,1}(?:(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])|(?:[0-9a-fA-F]{1,4}:){1,4}:(?:(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
|
|
1035
1035
|
return ipv6Regex.test(ip);
|
|
1036
1036
|
}
|
|
1037
1037
|
function isIPRange(ip) {
|
|
@@ -1051,7 +1051,7 @@ function isIPRange(ip) {
|
|
|
1051
1051
|
}
|
|
1052
1052
|
}
|
|
1053
1053
|
function isMACAddress(macAddress) {
|
|
1054
|
-
const macRegex = /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/;
|
|
1054
|
+
const macRegex = /^(?:[0-9A-Fa-f]{2}[:-]){5}(?:[0-9A-Fa-f]{2})$/;
|
|
1055
1055
|
return macRegex.test(macAddress);
|
|
1056
1056
|
}
|
|
1057
1057
|
function isLatLong(latlong) {
|
|
@@ -1063,11 +1063,11 @@ function isLatLong(latlong) {
|
|
|
1063
1063
|
return !isNaN(lat) && !isNaN(long) && lat >= -90 && lat <= 90 && long >= -180 && long <= 180;
|
|
1064
1064
|
}
|
|
1065
1065
|
function isCurrency(currency) {
|
|
1066
|
-
const currencyRegex = /^[$\u00A3\u20AC\u00A5]?\d{1,3}(
|
|
1066
|
+
const currencyRegex = /^[$\u00A3\u20AC\u00A5]?\d{1,3}(?:,?\d{3})*(?:\.\d{2})?$/;
|
|
1067
1067
|
return currencyRegex.test(currency.trim());
|
|
1068
1068
|
}
|
|
1069
1069
|
function isDataURI(dataURI) {
|
|
1070
|
-
const dataURIRegex = /^data:([a-z]+\/[a-z0-9-+.]+(
|
|
1070
|
+
const dataURIRegex = /^data:(?:[a-z]+\/[a-z0-9-+.]+(?:;[a-z-]+=[a-z0-9-]+)*)?;base64,(?:[a-z0-9+/]+=*)/i;
|
|
1071
1071
|
return dataURIRegex.test(dataURI) || /^data:,/.test(dataURI);
|
|
1072
1072
|
}
|
|
1073
1073
|
function isMimeType(mimeType) {
|
|
@@ -1100,7 +1100,7 @@ function isByteLength(str2, options) {
|
|
|
1100
1100
|
return byteLength >= min && byteLength <= max;
|
|
1101
1101
|
}
|
|
1102
1102
|
function isFQDN(fqdn) {
|
|
1103
|
-
const fqdnRegex = /^(?=.{1,253}$)((?!-)[A-Za-z0-9-]{1,63}(?<!-)\.)+[A-Za-z]{2,}$/;
|
|
1103
|
+
const fqdnRegex = /^(?=.{1,253}$)(?:(?!-)[A-Za-z0-9-]{1,63}(?<!-)\.)+[A-Za-z]{2,}$/;
|
|
1104
1104
|
return fqdnRegex.test(fqdn);
|
|
1105
1105
|
}
|
|
1106
1106
|
function isFullWidth(fullWidth) {
|
|
@@ -1123,7 +1123,7 @@ function isHash(hash, algorithm) {
|
|
|
1123
1123
|
return hash.length === expectedLength && /^[a-f0-9]+$/i.test(hash);
|
|
1124
1124
|
}
|
|
1125
1125
|
function isHSL(hsl) {
|
|
1126
|
-
const hslRegex = /^hsl\(
|
|
1126
|
+
const hslRegex = /^hsl\(?:\s*(?:\d+)\s*,\s*(?:\d+(?:\.\d+)?%)\s*,\s*(?:\d+(?:\.\d+)?%)\s*\)$/;
|
|
1127
1127
|
return hslRegex.test(hsl);
|
|
1128
1128
|
}
|
|
1129
1129
|
function isIBAN(iban) {
|
|
@@ -1169,7 +1169,7 @@ function isISIN(isin) {
|
|
|
1169
1169
|
return sum % 10 === 0;
|
|
1170
1170
|
}
|
|
1171
1171
|
function isISO8601(iso8601) {
|
|
1172
|
-
const iso8601Regex = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(
|
|
1172
|
+
const iso8601Regex = /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d{3})?(?:Z|[+-]\d{2}:\d{2})?)?$/;
|
|
1173
1173
|
if (!iso8601Regex.test(iso8601))
|
|
1174
1174
|
return false;
|
|
1175
1175
|
try {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/strings",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.70.
|
|
4
|
+
"version": "0.70.26",
|
|
5
5
|
"description": "The Stacks string utilities.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"contributors": [
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
],
|
|
39
39
|
"exports": {
|
|
40
40
|
".": {
|
|
41
|
-
"bun": "./src/index.ts",
|
|
42
41
|
"types": "./dist/index.d.ts",
|
|
42
|
+
"bun": "./src/index.ts",
|
|
43
43
|
"import": "./dist/index.js"
|
|
44
44
|
},
|
|
45
45
|
"./*": {
|