react-util-tools 1.0.25 → 1.0.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/README.md +38 -0
- package/dist/index.cjs +317 -0
- package/dist/index.d.cts +45 -1
- package/dist/index.d.ts +45 -1
- package/dist/index.js +274 -0
- package/package.json +1 -1
- package/src/index.ts +45 -0
- package/src/string/README.md +441 -0
- package/src/string/index.ts +527 -0
package/README.md
CHANGED
|
@@ -145,6 +145,19 @@ const total = new Decimal('0.1').plus('0.2') // Decimal(0.3)
|
|
|
145
145
|
|
|
146
146
|
[查看文档](./src/excel/README.md)
|
|
147
147
|
|
|
148
|
+
### 🔤 String - 字符串工具
|
|
149
|
+
强大的字符串处理工具集合:
|
|
150
|
+
- `camelCase()` / `snakeCase()` / `kebabCase()` - 命名转换
|
|
151
|
+
- `truncate()` / `padStart()` / `padEnd()` - 字符串操作
|
|
152
|
+
- `maskPhone()` / `maskIdCard()` / `maskBankCard()` - 数据脱敏
|
|
153
|
+
- `isValidPhone()` / `isValidEmail()` / `isValidUrl()` - 格式验证
|
|
154
|
+
- `randomString()` / `uuid()` - 随机生成
|
|
155
|
+
- `toBase64()` / `fromBase64()` - Base64 编解码
|
|
156
|
+
- `escapeHtml()` / `stripHtml()` - HTML 处理
|
|
157
|
+
- 更多...
|
|
158
|
+
|
|
159
|
+
[查看文档](./src/string/README.md)
|
|
160
|
+
|
|
148
161
|
## 使用示例
|
|
149
162
|
|
|
150
163
|
### 节流防抖
|
|
@@ -302,6 +315,31 @@ function exportData() {
|
|
|
302
315
|
}
|
|
303
316
|
```
|
|
304
317
|
|
|
318
|
+
### 字符串处理
|
|
319
|
+
|
|
320
|
+
```typescript
|
|
321
|
+
import {
|
|
322
|
+
camelCase,
|
|
323
|
+
maskPhone,
|
|
324
|
+
isValidEmail,
|
|
325
|
+
randomString,
|
|
326
|
+
uuid
|
|
327
|
+
} from 'react-tools'
|
|
328
|
+
|
|
329
|
+
// 命名转换
|
|
330
|
+
camelCase('hello-world') // 'helloWorld'
|
|
331
|
+
|
|
332
|
+
// 数据脱敏
|
|
333
|
+
maskPhone('13812345678') // '138****5678'
|
|
334
|
+
|
|
335
|
+
// 格式验证
|
|
336
|
+
isValidEmail('test@example.com') // true
|
|
337
|
+
|
|
338
|
+
// 随机生成
|
|
339
|
+
randomString(8) // 'aB3xY9Zk'
|
|
340
|
+
uuid() // '550e8400-e29b-41d4-a716-446655440000'
|
|
341
|
+
```
|
|
342
|
+
|
|
305
343
|
## TypeScript 支持
|
|
306
344
|
|
|
307
345
|
完整的 TypeScript 类型支持,开箱即用。
|
package/dist/index.cjs
CHANGED
|
@@ -39,13 +39,19 @@ __export(index_exports, {
|
|
|
39
39
|
addMonthsToDate: () => addMonthsToDate,
|
|
40
40
|
addMonthsUTC: () => addMonthsUTC,
|
|
41
41
|
aoaToSheet: () => aoaToSheet,
|
|
42
|
+
camelCase: () => camelCase,
|
|
43
|
+
capitalize: () => capitalize,
|
|
42
44
|
ceil: () => ceil,
|
|
43
45
|
clearAllCookies: () => clearAllCookies,
|
|
46
|
+
countOccurrences: () => countOccurrences,
|
|
44
47
|
debounce: () => debounceFn,
|
|
45
48
|
divide: () => divide,
|
|
49
|
+
endsWith: () => endsWith,
|
|
46
50
|
equals: () => equals,
|
|
51
|
+
escapeHtml: () => escapeHtml,
|
|
47
52
|
exportExcelFile: () => exportExcelFile,
|
|
48
53
|
exportJSONToExcel: () => exportJSONToExcel,
|
|
54
|
+
extractNumbers: () => extractNumbers,
|
|
49
55
|
floor: () => floor,
|
|
50
56
|
formatDate: () => formatDate,
|
|
51
57
|
formatDateOnly: () => formatDateOnly,
|
|
@@ -58,6 +64,7 @@ __export(index_exports, {
|
|
|
58
64
|
formatUTC: () => formatUTC,
|
|
59
65
|
formatUTCDateOnly: () => formatUTCDateOnly,
|
|
60
66
|
formatUTCTimeOnly: () => formatUTCTimeOnly,
|
|
67
|
+
fromBase64: () => fromBase64,
|
|
61
68
|
fromUTC: () => fromUTC,
|
|
62
69
|
getAllCookies: () => getAllCookies,
|
|
63
70
|
getAllQueryParams: () => getAllQueryParams,
|
|
@@ -112,35 +119,61 @@ __export(index_exports, {
|
|
|
112
119
|
greaterThan: () => greaterThan,
|
|
113
120
|
greaterThanOrEqual: () => greaterThanOrEqual,
|
|
114
121
|
hasCookie: () => hasCookie,
|
|
122
|
+
includes: () => includes,
|
|
115
123
|
isAfterDate: () => isAfterDate,
|
|
116
124
|
isAndroid: () => isAndroid,
|
|
117
125
|
isBeforeDate: () => isBeforeDate,
|
|
118
126
|
isDesktop: () => isDesktop,
|
|
127
|
+
isEmpty: () => isEmpty,
|
|
119
128
|
isIOS: () => isIOS,
|
|
120
129
|
isMobile: () => isMobile,
|
|
130
|
+
isNotEmpty: () => isNotEmpty,
|
|
121
131
|
isSameDayDate: () => isSameDayDate,
|
|
122
132
|
isTablet: () => isTablet,
|
|
123
133
|
isTouchDevice: () => isTouchDevice,
|
|
124
134
|
isValidDate: () => isValidDate,
|
|
135
|
+
isValidEmail: () => isValidEmail,
|
|
136
|
+
isValidIdCard: () => isValidIdCard,
|
|
137
|
+
isValidPhone: () => isValidPhone,
|
|
138
|
+
isValidUrl: () => isValidUrl,
|
|
125
139
|
isWeChat: () => isWeChat,
|
|
126
140
|
jsonToWorkbook: () => jsonToWorkbook,
|
|
141
|
+
kebabCase: () => kebabCase,
|
|
142
|
+
length: () => length,
|
|
127
143
|
lessThan: () => lessThan,
|
|
128
144
|
lessThanOrEqual: () => lessThanOrEqual,
|
|
145
|
+
maskBankCard: () => maskBankCard,
|
|
129
146
|
maskEmail: () => maskEmail,
|
|
147
|
+
maskIdCard: () => maskIdCard,
|
|
148
|
+
maskName: () => maskName,
|
|
149
|
+
maskPhone: () => maskPhone,
|
|
130
150
|
multiply: () => multiply,
|
|
131
151
|
negate: () => negate,
|
|
152
|
+
normalizeSpaces: () => normalizeSpaces,
|
|
153
|
+
padEnd: () => padEnd,
|
|
154
|
+
padStart: () => padStart,
|
|
132
155
|
parseDate: () => parseDate,
|
|
133
156
|
parseMoney: () => parseMoney,
|
|
157
|
+
pascalCase: () => pascalCase,
|
|
158
|
+
randomString: () => randomString,
|
|
134
159
|
read: () => read2,
|
|
135
160
|
readExcelFile: () => readExcelFile,
|
|
136
161
|
readExcelToJSON: () => readExcelToJSON,
|
|
137
162
|
readFile: () => readFile,
|
|
138
163
|
removeCookie: () => removeCookie,
|
|
164
|
+
removeSpaces: () => removeSpaces,
|
|
165
|
+
repeat: () => repeat,
|
|
166
|
+
replaceAll: () => replaceAll,
|
|
167
|
+
reverse: () => reverse,
|
|
139
168
|
round: () => round,
|
|
140
169
|
setCookie: () => setCookie,
|
|
141
170
|
sheetToAOA: () => sheetToAOA,
|
|
142
171
|
sheetToCSV: () => sheetToCSV,
|
|
143
172
|
sheetToHTML: () => sheetToHTML,
|
|
173
|
+
snakeCase: () => snakeCase,
|
|
174
|
+
split: () => split,
|
|
175
|
+
startsWith: () => startsWith,
|
|
176
|
+
stripHtml: () => stripHtml,
|
|
144
177
|
subDaysFromDate: () => subDaysFromDate,
|
|
145
178
|
subDaysUTC: () => subDaysUTC,
|
|
146
179
|
subMonthsFromDate: () => subMonthsFromDate,
|
|
@@ -148,10 +181,20 @@ __export(index_exports, {
|
|
|
148
181
|
subtract: () => subtract,
|
|
149
182
|
tableToSheet: () => tableToSheet,
|
|
150
183
|
throttle: () => throttleFn,
|
|
184
|
+
titleCase: () => titleCase,
|
|
185
|
+
toBase64: () => toBase64,
|
|
151
186
|
toISOString: () => toISOString,
|
|
187
|
+
toLowerCase: () => toLowerCase,
|
|
152
188
|
toUTC: () => toUTC,
|
|
189
|
+
toUpperCase: () => toUpperCase,
|
|
190
|
+
trim: () => trim,
|
|
191
|
+
trimEnd: () => trimEnd,
|
|
192
|
+
trimStart: () => trimStart,
|
|
193
|
+
truncate: () => truncate,
|
|
194
|
+
unescapeHtml: () => unescapeHtml,
|
|
153
195
|
unmaskEmail: () => unmaskEmail,
|
|
154
196
|
utils: () => utils2,
|
|
197
|
+
uuid: () => uuid,
|
|
155
198
|
workbookToJSON: () => workbookToJSON,
|
|
156
199
|
write: () => write,
|
|
157
200
|
writeFile: () => writeFile2,
|
|
@@ -1039,6 +1082,237 @@ function aoaToSheet(data, options) {
|
|
|
1039
1082
|
function sheetToAOA(worksheet, options) {
|
|
1040
1083
|
return XLSX.utils.sheet_to_json(worksheet, { ...options, header: 1 });
|
|
1041
1084
|
}
|
|
1085
|
+
|
|
1086
|
+
// src/string/index.ts
|
|
1087
|
+
function capitalize(str) {
|
|
1088
|
+
if (!str) return "";
|
|
1089
|
+
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
1090
|
+
}
|
|
1091
|
+
function camelCase(str) {
|
|
1092
|
+
if (!str) return "";
|
|
1093
|
+
return str.replace(/[-_\s]+(.)?/g, (_, char) => char ? char.toUpperCase() : "").replace(/^[A-Z]/, (char) => char.toLowerCase());
|
|
1094
|
+
}
|
|
1095
|
+
function pascalCase(str) {
|
|
1096
|
+
if (!str) return "";
|
|
1097
|
+
const camel = camelCase(str);
|
|
1098
|
+
return camel.charAt(0).toUpperCase() + camel.slice(1);
|
|
1099
|
+
}
|
|
1100
|
+
function snakeCase(str) {
|
|
1101
|
+
if (!str) return "";
|
|
1102
|
+
return str.replace(/([A-Z])/g, "_$1").replace(/[-\s]+/g, "_").replace(/^_/, "").toLowerCase();
|
|
1103
|
+
}
|
|
1104
|
+
function kebabCase(str) {
|
|
1105
|
+
if (!str) return "";
|
|
1106
|
+
return str.replace(/([A-Z])/g, "-$1").replace(/[_\s]+/g, "-").replace(/^-/, "").toLowerCase();
|
|
1107
|
+
}
|
|
1108
|
+
function truncate(str, length2, suffix = "...") {
|
|
1109
|
+
if (!str || str.length <= length2) return str;
|
|
1110
|
+
return str.slice(0, length2) + suffix;
|
|
1111
|
+
}
|
|
1112
|
+
function trim(str) {
|
|
1113
|
+
return str ? str.trim() : "";
|
|
1114
|
+
}
|
|
1115
|
+
function trimStart(str) {
|
|
1116
|
+
return str ? str.trimStart() : "";
|
|
1117
|
+
}
|
|
1118
|
+
function trimEnd(str) {
|
|
1119
|
+
return str ? str.trimEnd() : "";
|
|
1120
|
+
}
|
|
1121
|
+
function reverse(str) {
|
|
1122
|
+
if (!str) return "";
|
|
1123
|
+
return str.split("").reverse().join("");
|
|
1124
|
+
}
|
|
1125
|
+
function repeat(str, count) {
|
|
1126
|
+
if (!str || count <= 0) return "";
|
|
1127
|
+
return str.repeat(count);
|
|
1128
|
+
}
|
|
1129
|
+
function padStart(str, length2, padStr = " ") {
|
|
1130
|
+
if (!str) return padStr.repeat(length2);
|
|
1131
|
+
return str.padStart(length2, padStr);
|
|
1132
|
+
}
|
|
1133
|
+
function padEnd(str, length2, padStr = " ") {
|
|
1134
|
+
if (!str) return padStr.repeat(length2);
|
|
1135
|
+
return str.padEnd(length2, padStr);
|
|
1136
|
+
}
|
|
1137
|
+
function startsWith(str, searchString) {
|
|
1138
|
+
if (!str) return false;
|
|
1139
|
+
return str.startsWith(searchString);
|
|
1140
|
+
}
|
|
1141
|
+
function endsWith(str, searchString) {
|
|
1142
|
+
if (!str) return false;
|
|
1143
|
+
return str.endsWith(searchString);
|
|
1144
|
+
}
|
|
1145
|
+
function includes(str, searchString) {
|
|
1146
|
+
if (!str) return false;
|
|
1147
|
+
return str.includes(searchString);
|
|
1148
|
+
}
|
|
1149
|
+
function replaceAll(str, search, replacement) {
|
|
1150
|
+
if (!str) return "";
|
|
1151
|
+
if (typeof search === "string") {
|
|
1152
|
+
return str.split(search).join(replacement);
|
|
1153
|
+
}
|
|
1154
|
+
return str.replace(search, replacement);
|
|
1155
|
+
}
|
|
1156
|
+
function stripHtml(str) {
|
|
1157
|
+
if (!str) return "";
|
|
1158
|
+
return str.replace(/<[^>]*>/g, "");
|
|
1159
|
+
}
|
|
1160
|
+
function escapeHtml(str) {
|
|
1161
|
+
if (!str) return "";
|
|
1162
|
+
const map = {
|
|
1163
|
+
"&": "&",
|
|
1164
|
+
"<": "<",
|
|
1165
|
+
">": ">",
|
|
1166
|
+
'"': """,
|
|
1167
|
+
"'": "'"
|
|
1168
|
+
};
|
|
1169
|
+
return str.replace(/[&<>"']/g, (char) => map[char]);
|
|
1170
|
+
}
|
|
1171
|
+
function unescapeHtml(str) {
|
|
1172
|
+
if (!str) return "";
|
|
1173
|
+
const map = {
|
|
1174
|
+
"&": "&",
|
|
1175
|
+
"<": "<",
|
|
1176
|
+
">": ">",
|
|
1177
|
+
""": '"',
|
|
1178
|
+
"'": "'"
|
|
1179
|
+
};
|
|
1180
|
+
return str.replace(/&(amp|lt|gt|quot|#39);/g, (entity) => map[entity]);
|
|
1181
|
+
}
|
|
1182
|
+
function toLowerCase(str) {
|
|
1183
|
+
return str ? str.toLowerCase() : "";
|
|
1184
|
+
}
|
|
1185
|
+
function toUpperCase(str) {
|
|
1186
|
+
return str ? str.toUpperCase() : "";
|
|
1187
|
+
}
|
|
1188
|
+
function titleCase(str) {
|
|
1189
|
+
if (!str) return "";
|
|
1190
|
+
return str.toLowerCase().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
1191
|
+
}
|
|
1192
|
+
function isEmpty(str) {
|
|
1193
|
+
return !str || str.trim().length === 0;
|
|
1194
|
+
}
|
|
1195
|
+
function isNotEmpty(str) {
|
|
1196
|
+
return !isEmpty(str);
|
|
1197
|
+
}
|
|
1198
|
+
function length(str) {
|
|
1199
|
+
if (!str) return 0;
|
|
1200
|
+
return Array.from(str).length;
|
|
1201
|
+
}
|
|
1202
|
+
function split(str, separator) {
|
|
1203
|
+
if (!str) return [];
|
|
1204
|
+
return str.split(separator);
|
|
1205
|
+
}
|
|
1206
|
+
function extractNumbers(str) {
|
|
1207
|
+
if (!str) return [];
|
|
1208
|
+
const matches = str.match(/\d+(\.\d+)?/g);
|
|
1209
|
+
return matches ? matches.map(Number) : [];
|
|
1210
|
+
}
|
|
1211
|
+
function removeSpaces(str) {
|
|
1212
|
+
if (!str) return "";
|
|
1213
|
+
return str.replace(/\s+/g, "");
|
|
1214
|
+
}
|
|
1215
|
+
function normalizeSpaces(str) {
|
|
1216
|
+
if (!str) return "";
|
|
1217
|
+
return str.replace(/\s+/g, " ").trim();
|
|
1218
|
+
}
|
|
1219
|
+
function countOccurrences(str, searchString) {
|
|
1220
|
+
if (!str || !searchString) return 0;
|
|
1221
|
+
return str.split(searchString).length - 1;
|
|
1222
|
+
}
|
|
1223
|
+
function randomString(length2, chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") {
|
|
1224
|
+
let result = "";
|
|
1225
|
+
for (let i = 0; i < length2; i++) {
|
|
1226
|
+
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
1227
|
+
}
|
|
1228
|
+
return result;
|
|
1229
|
+
}
|
|
1230
|
+
function uuid() {
|
|
1231
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
1232
|
+
const r = Math.random() * 16 | 0;
|
|
1233
|
+
const v = c === "x" ? r : r & 3 | 8;
|
|
1234
|
+
return v.toString(16);
|
|
1235
|
+
});
|
|
1236
|
+
}
|
|
1237
|
+
function maskPhone(phone) {
|
|
1238
|
+
if (!phone || phone.length < 11) return phone;
|
|
1239
|
+
return phone.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2");
|
|
1240
|
+
}
|
|
1241
|
+
function maskIdCard(idCard) {
|
|
1242
|
+
if (!idCard || idCard.length < 18) return idCard;
|
|
1243
|
+
return idCard.replace(/(\d{6})\d{8}(\d{4})/, "$1********$2");
|
|
1244
|
+
}
|
|
1245
|
+
function maskBankCard(cardNumber) {
|
|
1246
|
+
if (!cardNumber || cardNumber.length < 16) return cardNumber;
|
|
1247
|
+
return cardNumber.replace(/(\d{4})\d+(\d{4})/, "$1 **** **** $2");
|
|
1248
|
+
}
|
|
1249
|
+
function maskName(name) {
|
|
1250
|
+
if (!name) return "";
|
|
1251
|
+
if (name.length === 2) {
|
|
1252
|
+
return name.charAt(0) + "*";
|
|
1253
|
+
}
|
|
1254
|
+
return name.charAt(0) + "*".repeat(name.length - 2) + name.charAt(name.length - 1);
|
|
1255
|
+
}
|
|
1256
|
+
function isValidPhone(phone) {
|
|
1257
|
+
if (!phone) return false;
|
|
1258
|
+
return /^1[3-9]\d{9}$/.test(phone);
|
|
1259
|
+
}
|
|
1260
|
+
function isValidEmail(email) {
|
|
1261
|
+
if (!email) return false;
|
|
1262
|
+
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
|
|
1263
|
+
}
|
|
1264
|
+
function isValidUrl(url) {
|
|
1265
|
+
if (!url) return false;
|
|
1266
|
+
try {
|
|
1267
|
+
new URL(url);
|
|
1268
|
+
return true;
|
|
1269
|
+
} catch {
|
|
1270
|
+
return false;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
function isValidIdCard(idCard) {
|
|
1274
|
+
if (!idCard) return false;
|
|
1275
|
+
return /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(idCard);
|
|
1276
|
+
}
|
|
1277
|
+
function toBase64(str) {
|
|
1278
|
+
if (!str) return "";
|
|
1279
|
+
if (typeof window !== "undefined" && window.btoa) {
|
|
1280
|
+
try {
|
|
1281
|
+
return window.btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (_, p1) => {
|
|
1282
|
+
return String.fromCharCode(parseInt(p1, 16));
|
|
1283
|
+
}));
|
|
1284
|
+
} catch {
|
|
1285
|
+
return "";
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
try {
|
|
1289
|
+
const BufferClass = globalThis.Buffer;
|
|
1290
|
+
return BufferClass ? BufferClass.from(str, "utf-8").toString("base64") : "";
|
|
1291
|
+
} catch {
|
|
1292
|
+
return "";
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
function fromBase64(base64) {
|
|
1296
|
+
if (!base64) return "";
|
|
1297
|
+
if (typeof window !== "undefined" && window.atob) {
|
|
1298
|
+
try {
|
|
1299
|
+
const binary = window.atob(base64);
|
|
1300
|
+
const bytes = new Uint8Array(binary.length);
|
|
1301
|
+
for (let i = 0; i < binary.length; i++) {
|
|
1302
|
+
bytes[i] = binary.charCodeAt(i);
|
|
1303
|
+
}
|
|
1304
|
+
return new TextDecoder().decode(bytes);
|
|
1305
|
+
} catch {
|
|
1306
|
+
return "";
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
try {
|
|
1310
|
+
const BufferClass = globalThis.Buffer;
|
|
1311
|
+
return BufferClass ? BufferClass.from(base64, "base64").toString("utf-8") : "";
|
|
1312
|
+
} catch {
|
|
1313
|
+
return "";
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1042
1316
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1043
1317
|
0 && (module.exports = {
|
|
1044
1318
|
Decimal,
|
|
@@ -1050,13 +1324,19 @@ function sheetToAOA(worksheet, options) {
|
|
|
1050
1324
|
addMonthsToDate,
|
|
1051
1325
|
addMonthsUTC,
|
|
1052
1326
|
aoaToSheet,
|
|
1327
|
+
camelCase,
|
|
1328
|
+
capitalize,
|
|
1053
1329
|
ceil,
|
|
1054
1330
|
clearAllCookies,
|
|
1331
|
+
countOccurrences,
|
|
1055
1332
|
debounce,
|
|
1056
1333
|
divide,
|
|
1334
|
+
endsWith,
|
|
1057
1335
|
equals,
|
|
1336
|
+
escapeHtml,
|
|
1058
1337
|
exportExcelFile,
|
|
1059
1338
|
exportJSONToExcel,
|
|
1339
|
+
extractNumbers,
|
|
1060
1340
|
floor,
|
|
1061
1341
|
formatDate,
|
|
1062
1342
|
formatDateOnly,
|
|
@@ -1069,6 +1349,7 @@ function sheetToAOA(worksheet, options) {
|
|
|
1069
1349
|
formatUTC,
|
|
1070
1350
|
formatUTCDateOnly,
|
|
1071
1351
|
formatUTCTimeOnly,
|
|
1352
|
+
fromBase64,
|
|
1072
1353
|
fromUTC,
|
|
1073
1354
|
getAllCookies,
|
|
1074
1355
|
getAllQueryParams,
|
|
@@ -1123,35 +1404,61 @@ function sheetToAOA(worksheet, options) {
|
|
|
1123
1404
|
greaterThan,
|
|
1124
1405
|
greaterThanOrEqual,
|
|
1125
1406
|
hasCookie,
|
|
1407
|
+
includes,
|
|
1126
1408
|
isAfterDate,
|
|
1127
1409
|
isAndroid,
|
|
1128
1410
|
isBeforeDate,
|
|
1129
1411
|
isDesktop,
|
|
1412
|
+
isEmpty,
|
|
1130
1413
|
isIOS,
|
|
1131
1414
|
isMobile,
|
|
1415
|
+
isNotEmpty,
|
|
1132
1416
|
isSameDayDate,
|
|
1133
1417
|
isTablet,
|
|
1134
1418
|
isTouchDevice,
|
|
1135
1419
|
isValidDate,
|
|
1420
|
+
isValidEmail,
|
|
1421
|
+
isValidIdCard,
|
|
1422
|
+
isValidPhone,
|
|
1423
|
+
isValidUrl,
|
|
1136
1424
|
isWeChat,
|
|
1137
1425
|
jsonToWorkbook,
|
|
1426
|
+
kebabCase,
|
|
1427
|
+
length,
|
|
1138
1428
|
lessThan,
|
|
1139
1429
|
lessThanOrEqual,
|
|
1430
|
+
maskBankCard,
|
|
1140
1431
|
maskEmail,
|
|
1432
|
+
maskIdCard,
|
|
1433
|
+
maskName,
|
|
1434
|
+
maskPhone,
|
|
1141
1435
|
multiply,
|
|
1142
1436
|
negate,
|
|
1437
|
+
normalizeSpaces,
|
|
1438
|
+
padEnd,
|
|
1439
|
+
padStart,
|
|
1143
1440
|
parseDate,
|
|
1144
1441
|
parseMoney,
|
|
1442
|
+
pascalCase,
|
|
1443
|
+
randomString,
|
|
1145
1444
|
read,
|
|
1146
1445
|
readExcelFile,
|
|
1147
1446
|
readExcelToJSON,
|
|
1148
1447
|
readFile,
|
|
1149
1448
|
removeCookie,
|
|
1449
|
+
removeSpaces,
|
|
1450
|
+
repeat,
|
|
1451
|
+
replaceAll,
|
|
1452
|
+
reverse,
|
|
1150
1453
|
round,
|
|
1151
1454
|
setCookie,
|
|
1152
1455
|
sheetToAOA,
|
|
1153
1456
|
sheetToCSV,
|
|
1154
1457
|
sheetToHTML,
|
|
1458
|
+
snakeCase,
|
|
1459
|
+
split,
|
|
1460
|
+
startsWith,
|
|
1461
|
+
stripHtml,
|
|
1155
1462
|
subDaysFromDate,
|
|
1156
1463
|
subDaysUTC,
|
|
1157
1464
|
subMonthsFromDate,
|
|
@@ -1159,10 +1466,20 @@ function sheetToAOA(worksheet, options) {
|
|
|
1159
1466
|
subtract,
|
|
1160
1467
|
tableToSheet,
|
|
1161
1468
|
throttle,
|
|
1469
|
+
titleCase,
|
|
1470
|
+
toBase64,
|
|
1162
1471
|
toISOString,
|
|
1472
|
+
toLowerCase,
|
|
1163
1473
|
toUTC,
|
|
1474
|
+
toUpperCase,
|
|
1475
|
+
trim,
|
|
1476
|
+
trimEnd,
|
|
1477
|
+
trimStart,
|
|
1478
|
+
truncate,
|
|
1479
|
+
unescapeHtml,
|
|
1164
1480
|
unmaskEmail,
|
|
1165
1481
|
utils,
|
|
1482
|
+
uuid,
|
|
1166
1483
|
workbookToJSON,
|
|
1167
1484
|
write,
|
|
1168
1485
|
writeFile,
|
package/dist/index.d.cts
CHANGED
|
@@ -190,4 +190,48 @@ declare function tableToSheet(table: HTMLElement | string, options?: XLSX.Table2
|
|
|
190
190
|
declare function aoaToSheet(data: any[][], options?: XLSX.AOA2SheetOpts): XLSX.WorkSheet;
|
|
191
191
|
declare function sheetToAOA(worksheet: XLSX.WorkSheet, options?: XLSX.Sheet2JSONOpts): any[][];
|
|
192
192
|
|
|
193
|
-
|
|
193
|
+
declare function capitalize(str: string): string;
|
|
194
|
+
declare function camelCase(str: string): string;
|
|
195
|
+
declare function pascalCase(str: string): string;
|
|
196
|
+
declare function snakeCase(str: string): string;
|
|
197
|
+
declare function kebabCase(str: string): string;
|
|
198
|
+
declare function truncate(str: string, length: number, suffix?: string): string;
|
|
199
|
+
declare function trim(str: string): string;
|
|
200
|
+
declare function trimStart(str: string): string;
|
|
201
|
+
declare function trimEnd(str: string): string;
|
|
202
|
+
declare function reverse(str: string): string;
|
|
203
|
+
declare function repeat(str: string, count: number): string;
|
|
204
|
+
declare function padStart(str: string, length: number, padStr?: string): string;
|
|
205
|
+
declare function padEnd(str: string, length: number, padStr?: string): string;
|
|
206
|
+
declare function startsWith(str: string, searchString: string): boolean;
|
|
207
|
+
declare function endsWith(str: string, searchString: string): boolean;
|
|
208
|
+
declare function includes(str: string, searchString: string): boolean;
|
|
209
|
+
declare function replaceAll(str: string, search: string | RegExp, replacement: string): string;
|
|
210
|
+
declare function stripHtml(str: string): string;
|
|
211
|
+
declare function escapeHtml(str: string): string;
|
|
212
|
+
declare function unescapeHtml(str: string): string;
|
|
213
|
+
declare function toLowerCase(str: string): string;
|
|
214
|
+
declare function toUpperCase(str: string): string;
|
|
215
|
+
declare function titleCase(str: string): string;
|
|
216
|
+
declare function isEmpty(str: string): boolean;
|
|
217
|
+
declare function isNotEmpty(str: string): boolean;
|
|
218
|
+
declare function length(str: string): number;
|
|
219
|
+
declare function split(str: string, separator: string | RegExp): string[];
|
|
220
|
+
declare function extractNumbers(str: string): number[];
|
|
221
|
+
declare function removeSpaces(str: string): string;
|
|
222
|
+
declare function normalizeSpaces(str: string): string;
|
|
223
|
+
declare function countOccurrences(str: string, searchString: string): number;
|
|
224
|
+
declare function randomString(length: number, chars?: string): string;
|
|
225
|
+
declare function uuid(): string;
|
|
226
|
+
declare function maskPhone(phone: string): string;
|
|
227
|
+
declare function maskIdCard(idCard: string): string;
|
|
228
|
+
declare function maskBankCard(cardNumber: string): string;
|
|
229
|
+
declare function maskName(name: string): string;
|
|
230
|
+
declare function isValidPhone(phone: string): boolean;
|
|
231
|
+
declare function isValidEmail(email: string): boolean;
|
|
232
|
+
declare function isValidUrl(url: string): boolean;
|
|
233
|
+
declare function isValidIdCard(idCard: string): boolean;
|
|
234
|
+
declare function toBase64(str: string): string;
|
|
235
|
+
declare function fromBase64(base64: string): string;
|
|
236
|
+
|
|
237
|
+
export { type CookieOptions, abs, add, addDaysToDate, addDaysUTC, addMonthsToDate, addMonthsUTC, aoaToSheet, camelCase, capitalize, ceil, clearAllCookies, countOccurrences, debounceFn as debounce, divide, endsWith, equals, escapeHtml, exportExcelFile, exportJSONToExcel, extractNumbers, floor, formatDate, formatDateOnly, formatMoney, formatMoneyToChinese, formatNumber, formatPercent, formatRelativeTime, formatTimeOnly, formatUTC, formatUTCDateOnly, formatUTCTimeOnly, fromBase64, fromUTC, getAllCookies, getAllQueryParams, getBrowser, getBrowserEngine, getBrowserVersion, getCookie, getDaysDiff, getDeviceInfo, getDevicePixelRatio, getDeviceType, getEndOfDay, getEndOfMonth, getEndOfWeek, getEndOfYear, getHoursDiff, getMinutesDiff, getOS, getQueryParam, getQueryParamAll, getScreenResolution, getSheet, getSheetNames, getStartOfDay, getStartOfMonth, getStartOfWeek, getStartOfYear, getTimestamp, getTimestampInSeconds, getTimezoneOffset, getTimezoneOffsetHours, getUTCAllWeeksInYear, getUTCDaysDiff, getUTCEndOfDay, getUTCEndOfMonth, getUTCHoursDiff, getUTCMinutesDiff, getUTCNow, getUTCStartOfDay, getUTCStartOfMonth, getUTCTimestamp, getUTCTimestampInSeconds, getUTCWeekEnd, getUTCWeekNumber, getUTCWeekStart, getUTCWeeksInYear, getUTCYearEnd, getUTCYearEndTimestamp, getUTCYearStart, getUTCYearStartTimestamp, getViewportSize, greaterThan, greaterThanOrEqual, hasCookie, includes, isAfterDate, isAndroid, isBeforeDate, isDesktop, isEmpty, isIOS, isMobile, isNotEmpty, isSameDayDate, isTablet, isTouchDevice, isValidDate, isValidEmail, isValidIdCard, isValidPhone, isValidUrl, isWeChat, jsonToWorkbook, kebabCase, length, lessThan, lessThanOrEqual, maskBankCard, maskEmail, maskIdCard, maskName, maskPhone, multiply, negate, normalizeSpaces, padEnd, padStart, parseDate, parseMoney, pascalCase, randomString, read, readExcelFile, readExcelToJSON, readFile, removeCookie, removeSpaces, repeat, replaceAll, reverse, round, setCookie, sheetToAOA, sheetToCSV, sheetToHTML, snakeCase, split, startsWith, stripHtml, subDaysFromDate, subDaysUTC, subMonthsFromDate, subMonthsUTC, subtract, tableToSheet, throttleFn as throttle, titleCase, toBase64, toISOString, toLowerCase, toUTC, toUpperCase, trim, trimEnd, trimStart, truncate, unescapeHtml, unmaskEmail, utils, uuid, workbookToJSON, write, writeFile, writeFileXLSX };
|
package/dist/index.d.ts
CHANGED
|
@@ -190,4 +190,48 @@ declare function tableToSheet(table: HTMLElement | string, options?: XLSX.Table2
|
|
|
190
190
|
declare function aoaToSheet(data: any[][], options?: XLSX.AOA2SheetOpts): XLSX.WorkSheet;
|
|
191
191
|
declare function sheetToAOA(worksheet: XLSX.WorkSheet, options?: XLSX.Sheet2JSONOpts): any[][];
|
|
192
192
|
|
|
193
|
-
|
|
193
|
+
declare function capitalize(str: string): string;
|
|
194
|
+
declare function camelCase(str: string): string;
|
|
195
|
+
declare function pascalCase(str: string): string;
|
|
196
|
+
declare function snakeCase(str: string): string;
|
|
197
|
+
declare function kebabCase(str: string): string;
|
|
198
|
+
declare function truncate(str: string, length: number, suffix?: string): string;
|
|
199
|
+
declare function trim(str: string): string;
|
|
200
|
+
declare function trimStart(str: string): string;
|
|
201
|
+
declare function trimEnd(str: string): string;
|
|
202
|
+
declare function reverse(str: string): string;
|
|
203
|
+
declare function repeat(str: string, count: number): string;
|
|
204
|
+
declare function padStart(str: string, length: number, padStr?: string): string;
|
|
205
|
+
declare function padEnd(str: string, length: number, padStr?: string): string;
|
|
206
|
+
declare function startsWith(str: string, searchString: string): boolean;
|
|
207
|
+
declare function endsWith(str: string, searchString: string): boolean;
|
|
208
|
+
declare function includes(str: string, searchString: string): boolean;
|
|
209
|
+
declare function replaceAll(str: string, search: string | RegExp, replacement: string): string;
|
|
210
|
+
declare function stripHtml(str: string): string;
|
|
211
|
+
declare function escapeHtml(str: string): string;
|
|
212
|
+
declare function unescapeHtml(str: string): string;
|
|
213
|
+
declare function toLowerCase(str: string): string;
|
|
214
|
+
declare function toUpperCase(str: string): string;
|
|
215
|
+
declare function titleCase(str: string): string;
|
|
216
|
+
declare function isEmpty(str: string): boolean;
|
|
217
|
+
declare function isNotEmpty(str: string): boolean;
|
|
218
|
+
declare function length(str: string): number;
|
|
219
|
+
declare function split(str: string, separator: string | RegExp): string[];
|
|
220
|
+
declare function extractNumbers(str: string): number[];
|
|
221
|
+
declare function removeSpaces(str: string): string;
|
|
222
|
+
declare function normalizeSpaces(str: string): string;
|
|
223
|
+
declare function countOccurrences(str: string, searchString: string): number;
|
|
224
|
+
declare function randomString(length: number, chars?: string): string;
|
|
225
|
+
declare function uuid(): string;
|
|
226
|
+
declare function maskPhone(phone: string): string;
|
|
227
|
+
declare function maskIdCard(idCard: string): string;
|
|
228
|
+
declare function maskBankCard(cardNumber: string): string;
|
|
229
|
+
declare function maskName(name: string): string;
|
|
230
|
+
declare function isValidPhone(phone: string): boolean;
|
|
231
|
+
declare function isValidEmail(email: string): boolean;
|
|
232
|
+
declare function isValidUrl(url: string): boolean;
|
|
233
|
+
declare function isValidIdCard(idCard: string): boolean;
|
|
234
|
+
declare function toBase64(str: string): string;
|
|
235
|
+
declare function fromBase64(base64: string): string;
|
|
236
|
+
|
|
237
|
+
export { type CookieOptions, abs, add, addDaysToDate, addDaysUTC, addMonthsToDate, addMonthsUTC, aoaToSheet, camelCase, capitalize, ceil, clearAllCookies, countOccurrences, debounceFn as debounce, divide, endsWith, equals, escapeHtml, exportExcelFile, exportJSONToExcel, extractNumbers, floor, formatDate, formatDateOnly, formatMoney, formatMoneyToChinese, formatNumber, formatPercent, formatRelativeTime, formatTimeOnly, formatUTC, formatUTCDateOnly, formatUTCTimeOnly, fromBase64, fromUTC, getAllCookies, getAllQueryParams, getBrowser, getBrowserEngine, getBrowserVersion, getCookie, getDaysDiff, getDeviceInfo, getDevicePixelRatio, getDeviceType, getEndOfDay, getEndOfMonth, getEndOfWeek, getEndOfYear, getHoursDiff, getMinutesDiff, getOS, getQueryParam, getQueryParamAll, getScreenResolution, getSheet, getSheetNames, getStartOfDay, getStartOfMonth, getStartOfWeek, getStartOfYear, getTimestamp, getTimestampInSeconds, getTimezoneOffset, getTimezoneOffsetHours, getUTCAllWeeksInYear, getUTCDaysDiff, getUTCEndOfDay, getUTCEndOfMonth, getUTCHoursDiff, getUTCMinutesDiff, getUTCNow, getUTCStartOfDay, getUTCStartOfMonth, getUTCTimestamp, getUTCTimestampInSeconds, getUTCWeekEnd, getUTCWeekNumber, getUTCWeekStart, getUTCWeeksInYear, getUTCYearEnd, getUTCYearEndTimestamp, getUTCYearStart, getUTCYearStartTimestamp, getViewportSize, greaterThan, greaterThanOrEqual, hasCookie, includes, isAfterDate, isAndroid, isBeforeDate, isDesktop, isEmpty, isIOS, isMobile, isNotEmpty, isSameDayDate, isTablet, isTouchDevice, isValidDate, isValidEmail, isValidIdCard, isValidPhone, isValidUrl, isWeChat, jsonToWorkbook, kebabCase, length, lessThan, lessThanOrEqual, maskBankCard, maskEmail, maskIdCard, maskName, maskPhone, multiply, negate, normalizeSpaces, padEnd, padStart, parseDate, parseMoney, pascalCase, randomString, read, readExcelFile, readExcelToJSON, readFile, removeCookie, removeSpaces, repeat, replaceAll, reverse, round, setCookie, sheetToAOA, sheetToCSV, sheetToHTML, snakeCase, split, startsWith, stripHtml, subDaysFromDate, subDaysUTC, subMonthsFromDate, subMonthsUTC, subtract, tableToSheet, throttleFn as throttle, titleCase, toBase64, toISOString, toLowerCase, toUTC, toUpperCase, trim, trimEnd, trimStart, truncate, unescapeHtml, unmaskEmail, utils, uuid, workbookToJSON, write, writeFile, writeFileXLSX };
|