@heyform-inc/utils 1.0.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/dist/index.mjs ADDED
@@ -0,0 +1,704 @@
1
+ export * from 'deep-object-diff';
2
+ import validatorIsUUID from 'validator/lib/isUUID';
3
+ import _clone from 'clone';
4
+ import dayjs from 'dayjs';
5
+ import * as m from 'mime-types';
6
+ import { customAlphabet } from 'nanoid';
7
+ import * as objectPath from 'object-path';
8
+ import slug from 'slugify';
9
+ export { v4 as uuidv4, v5 as uuidv5 } from 'uuid';
10
+
11
+ // src/index.ts
12
+
13
+ // src/type.ts
14
+ var toString = Object.prototype.toString;
15
+ function type(obj) {
16
+ if (obj === null) {
17
+ return "null";
18
+ }
19
+ let type2 = typeof obj;
20
+ if (type2 !== "object") {
21
+ return type2;
22
+ }
23
+ type2 = toString.call(obj).slice(8, -1);
24
+ const typeLower = type2.toLowerCase();
25
+ if (typeLower !== "object") {
26
+ if (typeLower === "number" || typeLower === "boolean" || typeLower === "string") {
27
+ return type2;
28
+ }
29
+ return typeLower;
30
+ }
31
+ return typeLower;
32
+ }
33
+ var whiteSpaceRegx = /^[\s\f\n\r\t\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000\ufeff\x09\x0a\x0b\x0c\x0d\x20\xa0]+$/;
34
+ var numericRegx = /^[+-]?([0-9]*[.])?[0-9]+$/;
35
+ var isUUID = validatorIsUUID;
36
+ function isBoolean(arg) {
37
+ return type(arg) === "boolean";
38
+ }
39
+ function isString(arg) {
40
+ return type(arg) === "string";
41
+ }
42
+ function isNumber(arg) {
43
+ return type(arg) === "number";
44
+ }
45
+ function isNumeric(arg) {
46
+ return numericRegx.test(String(arg));
47
+ }
48
+ var isArray = Array.isArray;
49
+ function isValidArray(arg) {
50
+ return isArray(arg) && arg.length > 0;
51
+ }
52
+ function isNan(arg) {
53
+ return isNumber(arg) && Number.isNaN(arg);
54
+ }
55
+ function isSet(arg) {
56
+ return type(arg) === "set";
57
+ }
58
+ function isMap(arg) {
59
+ return type(arg) === "map";
60
+ }
61
+ function isSymbol(arg) {
62
+ return type(arg) === "symbol";
63
+ }
64
+ function isObject(arg) {
65
+ return type(arg) === "object";
66
+ }
67
+ function isDate(arg) {
68
+ return type(arg) === "date";
69
+ }
70
+ function isRegExp(arg) {
71
+ return type(arg) === "regexp";
72
+ }
73
+ function isError(arg) {
74
+ return type(arg) === "error";
75
+ }
76
+ function isFunction(arg) {
77
+ return type(arg) === "function";
78
+ }
79
+ function isNull(arg) {
80
+ return type(arg) === "null";
81
+ }
82
+ function isUndefined(arg) {
83
+ return type(arg) === "undefined";
84
+ }
85
+ function isNil(arg) {
86
+ return isNull(arg) || isUndefined(arg);
87
+ }
88
+ function isPlainObject(arg) {
89
+ if (!isObject(arg))
90
+ return false;
91
+ const ctor = arg.constructor;
92
+ if (typeof ctor !== "function")
93
+ return false;
94
+ const proto = ctor.prototype;
95
+ if (!isObject(proto))
96
+ return false;
97
+ return proto.hasOwnProperty("isPrototypeOf");
98
+ }
99
+ function isEmpty(arg) {
100
+ if (isNil(arg))
101
+ return true;
102
+ if (isBoolean(arg))
103
+ return false;
104
+ if (isNumber(arg))
105
+ return false;
106
+ if (isString(arg)) {
107
+ return arg.length === 0 || whiteSpaceRegx.test(arg);
108
+ }
109
+ if (isFunction(arg) || isArray(arg)) {
110
+ return arg.length === 0;
111
+ }
112
+ switch (type(arg)) {
113
+ case "file":
114
+ case "map":
115
+ case "weakmap":
116
+ case "set":
117
+ case "weakset": {
118
+ return arg.size === 0;
119
+ }
120
+ case "object": {
121
+ for (const key in arg) {
122
+ if (Object.hasOwnProperty.call(arg, key))
123
+ return false;
124
+ }
125
+ return true;
126
+ }
127
+ }
128
+ return false;
129
+ }
130
+ function isValid(arg) {
131
+ return !isEmpty(arg);
132
+ }
133
+ function isEqual(arg1, arg2) {
134
+ return String(arg1) === String(arg2);
135
+ }
136
+ function isTrue(arg1) {
137
+ return arg1 === true || arg1 === "true" || isEqual(arg1, "1");
138
+ }
139
+ function isFalse(arg1) {
140
+ return arg1 === false || arg1 === "false" || isEqual(arg1, "0");
141
+ }
142
+ function isBool(arg) {
143
+ return isTrue(arg) || isFalse(arg);
144
+ }
145
+ function isFormData(arg) {
146
+ return type(arg) === "formdata";
147
+ }
148
+ function uniqueArray(arg) {
149
+ if (!isValidArray(arg)) {
150
+ return [];
151
+ }
152
+ return Array.from(new Set(arg));
153
+ }
154
+ function isURL(arg) {
155
+ if (isEmpty(arg)) {
156
+ return false;
157
+ }
158
+ try {
159
+ const url = new URL(arg);
160
+ return isValid(url.hostname);
161
+ } catch (err) {
162
+ return false;
163
+ }
164
+ }
165
+ var helper_default = {
166
+ isUUID,
167
+ isBoolean,
168
+ isString,
169
+ isNumber,
170
+ isNumeric,
171
+ isArray,
172
+ isValidArray,
173
+ isNan,
174
+ isSet,
175
+ isMap,
176
+ isSymbol,
177
+ isObject,
178
+ isDate,
179
+ isRegExp,
180
+ isError,
181
+ isFunction,
182
+ isNull,
183
+ isUndefined,
184
+ isNil,
185
+ isPlainObject,
186
+ isEmpty,
187
+ isValid,
188
+ isEqual,
189
+ isTrue,
190
+ isFalse,
191
+ isBool,
192
+ isURL,
193
+ isFormData,
194
+ uniqueArray
195
+ };
196
+
197
+ // src/bytes.ts
198
+ var BYTE = 1;
199
+ var KB = BYTE * 1024;
200
+ var MB = KB * 1024;
201
+ var GB = MB * 1024;
202
+ var TB = GB * 1024;
203
+ var PB = TB * 1024;
204
+ var regx = /^(-?(?:\d+)?\.?\d+)(b|kb|mb|gb|tb|pb)$/i;
205
+ function parseBytes(value) {
206
+ if (isEmpty(value)) {
207
+ return;
208
+ }
209
+ const str = String(value);
210
+ const matches = str.match(regx);
211
+ if (!matches) {
212
+ return;
213
+ }
214
+ const num = parseFloat(matches[1]);
215
+ const type2 = matches[2].toLowerCase();
216
+ switch (type2) {
217
+ case "pb":
218
+ return num * PB;
219
+ case "tb":
220
+ return num * TB;
221
+ case "gb":
222
+ return num * GB;
223
+ case "mb":
224
+ return num * MB;
225
+ case "kb":
226
+ return num * KB;
227
+ case "b":
228
+ return num * BYTE;
229
+ }
230
+ }
231
+ function bytes(size) {
232
+ return parseBytes(size);
233
+ }
234
+ function formatBytes(value) {
235
+ const mag = Math.abs(Number(value));
236
+ let unit;
237
+ let size;
238
+ if (mag >= PB) {
239
+ unit = "PB";
240
+ size = mag / PB;
241
+ } else if (mag >= TB) {
242
+ unit = "TB";
243
+ size = mag / TB;
244
+ } else if (mag >= GB) {
245
+ unit = "GB";
246
+ size = mag / GB;
247
+ } else if (mag >= MB) {
248
+ unit = "MB";
249
+ size = mag / MB;
250
+ } else if (mag >= KB) {
251
+ unit = "KB";
252
+ size = mag / KB;
253
+ } else {
254
+ unit = "B";
255
+ size = mag / BYTE;
256
+ }
257
+ if (String(size).includes(".")) {
258
+ size = size.toFixed(1);
259
+ }
260
+ return size + unit;
261
+ }
262
+ function clone(obj) {
263
+ return _clone(obj);
264
+ }
265
+
266
+ // src/color.ts
267
+ var HEX_REGEX = /^#?([0-9A-F]{3}|[0-9A-F]{4}|[0-9A-F]{6}|[0-9A-F]{8})$/i;
268
+ var RGBA_REGEX = /rgba\((\d{1,3}%?),\s*(\d{1,3}%?),\s*(\d{1,3}%?),\s*(\d*(?:\.\d+)?)\)/i;
269
+ var RGB_REGEX = /rgb\((\d{1,3}%?),\s*(\d{1,3}%?),\s*(\d{1,3}%?)\)/i;
270
+ function isHexColor(color) {
271
+ return HEX_REGEX.test(color);
272
+ }
273
+ function isRgba(color) {
274
+ return RGBA_REGEX.test(color);
275
+ }
276
+ function isRgb(color) {
277
+ return RGB_REGEX.test(color);
278
+ }
279
+ function hexToRgb(hex) {
280
+ if (isEmpty(hex)) {
281
+ return [];
282
+ }
283
+ if (isRgba(hex)) {
284
+ const [, red2, green2, blue2, alpha3] = RGBA_REGEX.exec(hex);
285
+ return [Number(red2), Number(green2), Number(blue2), Number(alpha3)];
286
+ }
287
+ if (isRgb(hex)) {
288
+ const [, red2, green2, blue2] = RGB_REGEX.exec(hex);
289
+ return [Number(red2), Number(green2), Number(blue2), 1];
290
+ }
291
+ if (!isHexColor(hex)) {
292
+ return [];
293
+ }
294
+ hex = hex.replace(/^#/, "");
295
+ if (hex.length === 3) {
296
+ hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
297
+ }
298
+ let alpha2 = 1;
299
+ if (hex.length === 8) {
300
+ alpha2 = hexToFloatAlpha(hex.slice(6, 8));
301
+ hex = hex.slice(0, 6);
302
+ }
303
+ const number = Number.parseInt(hex, 16);
304
+ const red = number >> 16;
305
+ const green = number >> 8 & 255;
306
+ const blue = number & 255;
307
+ return [red, green, blue, alpha2];
308
+ }
309
+ function isDarkColor(hex) {
310
+ if (!isHexColor(hex)) {
311
+ return true;
312
+ }
313
+ return colorBrightness(hex) < 170;
314
+ }
315
+ function isLightColor(hex) {
316
+ return !isDarkColor(hex);
317
+ }
318
+ function colorBrightness(hex) {
319
+ const [red, green, blue, alpha2] = hexToRgb(hex);
320
+ return alpha2 * (red * 299 + green * 587 + blue * 114) / 1e3;
321
+ }
322
+ function rgbToHex([r, g, b]) {
323
+ return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
324
+ }
325
+ function alpha(hex, alpha2) {
326
+ const [red, green, blue] = hexToRgb(hex);
327
+ return `rgba(${red}, ${green}, ${blue}, ${alpha2})`;
328
+ }
329
+ function lighten(hex, alpha2) {
330
+ return rgbToHex(alphaHexToRgb(hex, 1 - alpha2, "#fff"));
331
+ }
332
+ function darken(hex, alpha2) {
333
+ return rgbToHex(alphaHexToRgb(hex, 1 - alpha2, "#010101"));
334
+ }
335
+ function invert(hex) {
336
+ const [red, green, blue] = hexToRgb(hex);
337
+ return rgbToHex([255 - red, 255 - green, 255 - blue]);
338
+ }
339
+ function alphaHexToRgb(hex, alpha2, backgroundHex) {
340
+ const hexRgb = hexToRgb(hex);
341
+ const backgroundRgb = hexToRgb(backgroundHex);
342
+ return hexRgb.map((color, index) => {
343
+ return colorRange(
344
+ Math.floor(
345
+ colorRange(color) * alpha2 + colorRange(backgroundRgb[index]) * (1 - alpha2)
346
+ )
347
+ );
348
+ });
349
+ }
350
+ function colorRange(color) {
351
+ return color < 1 ? 1 : color >= 255 ? 255 : color;
352
+ }
353
+ function hexToFloatAlpha(arg) {
354
+ const num = parseInt(arg, 16);
355
+ const max = parseInt("0xff", 16);
356
+ return Number((num / max).toFixed(2));
357
+ }
358
+
359
+ // src/conv.ts
360
+ function toBool(value, defaults) {
361
+ if (isEmpty(value)) {
362
+ return defaults || false;
363
+ }
364
+ if (isBoolean(value)) {
365
+ return value;
366
+ }
367
+ return isTrue(value);
368
+ }
369
+
370
+ // src/hs.ts
371
+ var second = 1;
372
+ var minute = second * 60;
373
+ var hour = minute * 60;
374
+ var day = hour * 24;
375
+ var week = day * 7;
376
+ var year = day * 365;
377
+ var regx2 = /^(-?(?:\d+)?\.?\d+)(s|m|h|d|w|y)$/i;
378
+ function parse(arg) {
379
+ if (isEmpty(arg)) {
380
+ return;
381
+ }
382
+ const str = String(arg);
383
+ const matches = str.match(regx2);
384
+ if (!matches) {
385
+ return;
386
+ }
387
+ const num = parseFloat(matches[1]);
388
+ const type2 = matches[2].toLowerCase();
389
+ switch (type2) {
390
+ case "y":
391
+ return num * year;
392
+ case "w":
393
+ return num * week;
394
+ case "d":
395
+ return num * day;
396
+ case "h":
397
+ return num * hour;
398
+ case "m":
399
+ return num * minute;
400
+ case "s":
401
+ return num * second;
402
+ }
403
+ }
404
+ function hs(arg) {
405
+ const value = parse(arg);
406
+ if (value) {
407
+ return Math.round(value);
408
+ }
409
+ }
410
+ function ms(arg) {
411
+ const value = hs(arg);
412
+ if (value) {
413
+ return value * 1e3;
414
+ }
415
+ }
416
+ function timestamp() {
417
+ return Math.floor(Date.now() / 1e3);
418
+ }
419
+ function date(str, format) {
420
+ return dayjs(str, format);
421
+ }
422
+ function unixDate(t) {
423
+ return dayjs.unix(t);
424
+ }
425
+ function isDateExpired(start, end, expire) {
426
+ return end - start > hs(expire);
427
+ }
428
+ function unixDiff(start, end, unit = "day") {
429
+ if (start > end || start < 0 || end < 0) {
430
+ return 0;
431
+ }
432
+ return unixDate(end).diff(unixDate(start), unit);
433
+ }
434
+ function datePeriod(start, value = 1, unit = "month") {
435
+ return unixDate(start).add(value, unit).unix();
436
+ }
437
+ var commonImageMimeTypes = [
438
+ m.lookup(".jpg"),
439
+ m.lookup(".png"),
440
+ m.lookup(".bmp"),
441
+ m.lookup(".gif")
442
+ ];
443
+ var commonFileMimeTypes = [
444
+ ...commonImageMimeTypes,
445
+ m.lookup(".txt"),
446
+ m.lookup(".md"),
447
+ m.lookup(".doc"),
448
+ m.lookup(".docx"),
449
+ m.lookup(".xls"),
450
+ m.lookup(".xlsx"),
451
+ m.lookup(".csv"),
452
+ m.lookup(".ppt"),
453
+ m.lookup(".pptx"),
454
+ m.lookup(".pdf"),
455
+ m.lookup(".mp4"),
456
+ m.lookup(".wmv")
457
+ ];
458
+ var mime = m.lookup;
459
+ var NANOID_ALPHABET = "ModuleSymbhasOwnPr0123456789ABCDEFGHNRVfgctiUvzKqYTJkLxpZXIjQW";
460
+ function nanoid(len = 21) {
461
+ return nanoidCustomAlphabet(NANOID_ALPHABET, len);
462
+ }
463
+ function nanoidCustomAlphabet(alphabet, len = 21) {
464
+ const generate = customAlphabet(alphabet, len);
465
+ return generate();
466
+ }
467
+ function pickObject(target, fields, excludes = []) {
468
+ if (!isObject(target)) {
469
+ return {};
470
+ }
471
+ const copied = clone(target);
472
+ const targetKeys = Object.keys(copied);
473
+ const fieldAlias = {};
474
+ let picked = [];
475
+ if (fields.length > 0) {
476
+ fields.forEach((item) => {
477
+ if (isArray(item)) {
478
+ if (item.length > 0) {
479
+ const filed = item[0];
480
+ picked.push(filed);
481
+ if (item.length > 1) {
482
+ fieldAlias[filed] = item[1];
483
+ }
484
+ }
485
+ } else {
486
+ picked.push(item);
487
+ }
488
+ });
489
+ } else {
490
+ picked = targetKeys;
491
+ }
492
+ const newObj = {};
493
+ targetKeys.filter((key) => !excludes.includes(key) && picked.includes(key)).forEach((key) => {
494
+ const alias = fieldAlias[key];
495
+ if (alias) {
496
+ newObj[alias] = copied[key];
497
+ } else {
498
+ newObj[key] = copied[key];
499
+ }
500
+ });
501
+ return newObj;
502
+ }
503
+ function pickValidValues(target, fields) {
504
+ const dist = {};
505
+ fields.forEach((field) => {
506
+ let key = String(field);
507
+ let alias;
508
+ if (isArray(field)) {
509
+ key = field[0];
510
+ if (field.length > 1) {
511
+ alias = field[1];
512
+ }
513
+ }
514
+ let value = target[key];
515
+ if (isValid(value)) {
516
+ if (isPlainObject(value) || isArray(value)) {
517
+ value = clone(value);
518
+ }
519
+ dist[alias || key] = value;
520
+ }
521
+ });
522
+ return dist;
523
+ }
524
+ function removeObjectNil(target) {
525
+ if (!isObject(target)) {
526
+ return {};
527
+ }
528
+ const copied = clone(target);
529
+ const newObj = {};
530
+ for (const field of Object.keys(copied)) {
531
+ const value = copied[field];
532
+ if (isNil(value) || isNan(value)) {
533
+ continue;
534
+ }
535
+ newObj[field] = value;
536
+ }
537
+ return newObj;
538
+ }
539
+ function copyObjectValues(target, dist, keyMaps) {
540
+ if (!isObject(target) || !isObject(dist)) {
541
+ return;
542
+ }
543
+ for (const keys of keyMaps) {
544
+ let targetKey;
545
+ let distKey;
546
+ if (isArray(keys)) {
547
+ targetKey = keys[0];
548
+ distKey = keys[1];
549
+ } else {
550
+ targetKey = String(keys);
551
+ distKey = targetKey;
552
+ }
553
+ let value = objectPath.get(target, targetKey);
554
+ if (!isNil(value) && !isNan(value)) {
555
+ if (isPlainObject(value) || isArray(value)) {
556
+ value = clone(value);
557
+ }
558
+ objectPath.set(dist, distKey, value);
559
+ }
560
+ }
561
+ }
562
+
563
+ // src/parse.ts
564
+ function parseJson(str, defaultValue) {
565
+ let value;
566
+ try {
567
+ value = JSON.parse(str);
568
+ } catch (e) {
569
+ }
570
+ if (defaultValue && !value) {
571
+ value = defaultValue;
572
+ }
573
+ return value;
574
+ }
575
+ function parseBool(arg, defaultValue) {
576
+ if (isEmpty(arg)) {
577
+ return defaultValue || false;
578
+ }
579
+ if (isBoolean(arg)) {
580
+ return arg;
581
+ }
582
+ return isTrue(arg);
583
+ }
584
+ function parseNumber(arg, defaultValue, maxValue) {
585
+ if (isNumber(arg)) {
586
+ if (maxValue && maxValue < Number(arg)) {
587
+ return maxValue;
588
+ }
589
+ return Number(arg);
590
+ }
591
+ const num = parseInt(arg, 10);
592
+ if (isNaN(num)) {
593
+ return defaultValue;
594
+ }
595
+ if (maxValue && maxValue < num) {
596
+ return maxValue;
597
+ }
598
+ return num;
599
+ }
600
+ function htmlToText(html, limit = 100) {
601
+ let result = html.replace(/<style[^<>]*>((?!<\/).)*<\/style>/gi, "").replace(/<script[^<>]*>((?!<\/).)*<\/script>/gi, "").replace(/<[^>]+>/g, "").replace(/\t|\r|\n|\r\n/g, "").replace(/\s+/g, "").replace(/&nbsp;/g, " ").replace(/&quot;/g, '"').replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">");
602
+ if (limit > 0) {
603
+ result = result.slice(0, limit);
604
+ }
605
+ return result;
606
+ }
607
+
608
+ // src/qs.ts
609
+ function stringify(arg, options) {
610
+ const arr = [];
611
+ Object.keys(arg).forEach((key) => {
612
+ let val = arg[key];
613
+ if (isEmpty(val)) {
614
+ val = "";
615
+ } else {
616
+ val = String(val);
617
+ }
618
+ if (options?.encode) {
619
+ val = encodeURIComponent(val);
620
+ }
621
+ arr.push(`${key}=${val}`);
622
+ });
623
+ return arr.join("&");
624
+ }
625
+ function parse2(str, options) {
626
+ const obj = {};
627
+ if (!isString(str)) {
628
+ return obj;
629
+ }
630
+ const arr = str.replace(/^([^?]+)?\?/, "").split("&");
631
+ arr.forEach((param) => {
632
+ const paramArr = param.split("=");
633
+ const key = paramArr[0];
634
+ if (!isEmpty(key)) {
635
+ let val = paramArr[1];
636
+ if (options?.decode) {
637
+ val = decodeURIComponent(val);
638
+ }
639
+ val = options?.separator && val.includes(options?.separator) ? val.split(options?.separator) : val;
640
+ obj[key] = val;
641
+ }
642
+ });
643
+ return obj;
644
+ }
645
+ var qs_default = {
646
+ stringify,
647
+ parse: parse2
648
+ };
649
+
650
+ // src/random.ts
651
+ var numeric = "0123456789";
652
+ var hexic = "0123456789abcdef";
653
+ var lower = "abcdefghijklmnopqrstuvwxyz";
654
+ var upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
655
+ var length = 6;
656
+ var RandomType = /* @__PURE__ */ ((RandomType2) => {
657
+ RandomType2[RandomType2["LOWER"] = 0] = "LOWER";
658
+ RandomType2[RandomType2["UPPER"] = 1] = "UPPER";
659
+ RandomType2[RandomType2["NUMERIC"] = 2] = "NUMERIC";
660
+ RandomType2[RandomType2["HEXIC"] = 3] = "HEXIC";
661
+ RandomType2[RandomType2["LOWER_NUMERIC"] = 4] = "LOWER_NUMERIC";
662
+ RandomType2[RandomType2["UPPER_NUMERIC"] = 5] = "UPPER_NUMERIC";
663
+ RandomType2[RandomType2["ALPHANUMERIC"] = 6] = "ALPHANUMERIC";
664
+ return RandomType2;
665
+ })(RandomType || {});
666
+ function random(len = length * 2, type2 = 6 /* ALPHANUMERIC */) {
667
+ let alphabet = numeric + lower + upper;
668
+ switch (type2) {
669
+ case 0 /* LOWER */:
670
+ alphabet = lower;
671
+ break;
672
+ case 1 /* UPPER */:
673
+ alphabet = upper;
674
+ break;
675
+ case 3 /* HEXIC */:
676
+ alphabet = hexic;
677
+ break;
678
+ case 2 /* NUMERIC */:
679
+ alphabet = numeric;
680
+ break;
681
+ case 4 /* LOWER_NUMERIC */:
682
+ alphabet = lower + numeric;
683
+ break;
684
+ case 5 /* UPPER_NUMERIC */:
685
+ alphabet = upper + numeric;
686
+ break;
687
+ case 6 /* ALPHANUMERIC */:
688
+ alphabet = lower + upper + numeric;
689
+ break;
690
+ }
691
+ let str = "";
692
+ const alphabetLength = alphabet.length;
693
+ for (let i = 0; i < len; i++) {
694
+ str += alphabet.charAt(Math.floor(Math.random() * alphabetLength));
695
+ }
696
+ return str;
697
+ }
698
+ function slugify(text) {
699
+ return slug(text);
700
+ }
701
+
702
+ export { RandomType, alpha, alphaHexToRgb, bytes, clone, colorBrightness, commonFileMimeTypes, commonImageMimeTypes, copyObjectValues, darken, date, datePeriod, formatBytes, helper_default as helper, hexToRgb, hs, htmlToText, invert, isDarkColor, isDateExpired, isHexColor, isLightColor, isRgb, isRgba, lighten, mime, ms, nanoid, nanoidCustomAlphabet, parseBool, parseBytes, parseJson, parseNumber, pickObject, pickValidValues, qs_default as qs, random, removeObjectNil, rgbToHex, slugify, timestamp, toBool, type, unixDate, unixDiff };
703
+ //# sourceMappingURL=out.js.map
704
+ //# sourceMappingURL=index.mjs.map