@heyform-inc/utils 1.2.2 → 1.3.1
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.d.mts +157 -14
- package/dist/index.d.ts +157 -14
- package/dist/index.js +296 -61
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +265 -58
- package/dist/index.mjs.map +1 -1
- package/package.json +48 -30
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
export * from 'deep-object-diff';
|
|
2
2
|
import { parse, stringify } from 'qs';
|
|
3
3
|
export { default as qs } from 'qs';
|
|
4
|
-
import
|
|
4
|
+
import _isEmail from 'validator/lib/isEmail';
|
|
5
5
|
import _isFQDN from 'validator/lib/isFQDN';
|
|
6
6
|
import _isNumeric from 'validator/lib/isNumeric';
|
|
7
|
-
import _isEmail from 'validator/lib/isEmail';
|
|
8
7
|
import _isURL from 'validator/lib/isURL';
|
|
8
|
+
import _isUUID from 'validator/lib/isUUID';
|
|
9
9
|
import _clone from 'clone';
|
|
10
|
+
import { clsx as clsx$1 } from 'clsx';
|
|
11
|
+
import { twMerge } from 'tailwind-merge';
|
|
10
12
|
import { convert } from 'html-to-text';
|
|
11
|
-
import _ms from 'ms';
|
|
12
13
|
import _dayjs from 'dayjs';
|
|
14
|
+
import _ms from 'ms';
|
|
13
15
|
import { customAlphabet } from 'nanoid';
|
|
14
16
|
import * as objectPath from 'object-path';
|
|
15
17
|
export { deepEqual } from 'fast-equals';
|
|
@@ -270,6 +272,9 @@ function formatBytes(value) {
|
|
|
270
272
|
function clone(obj) {
|
|
271
273
|
return _clone(obj);
|
|
272
274
|
}
|
|
275
|
+
function clsx(...inputs) {
|
|
276
|
+
return twMerge(clsx$1(inputs));
|
|
277
|
+
}
|
|
273
278
|
|
|
274
279
|
// src/color.ts
|
|
275
280
|
var HEX_REGEX = /^#?([0-9A-F]{3}|[0-9A-F]{4}|[0-9A-F]{6}|[0-9A-F]{8})$/i;
|
|
@@ -349,9 +354,7 @@ function alphaHexToRgb(hex, alpha2, backgroundHex) {
|
|
|
349
354
|
const backgroundRgb = hexToRgb(backgroundHex);
|
|
350
355
|
return hexRgb.map((color, index) => {
|
|
351
356
|
return colorRange(
|
|
352
|
-
Math.floor(
|
|
353
|
-
colorRange(color) * alpha2 + colorRange(backgroundRgb[index]) * (1 - alpha2)
|
|
354
|
-
)
|
|
357
|
+
Math.floor(colorRange(color) * alpha2 + colorRange(backgroundRgb[index]) * (1 - alpha2))
|
|
355
358
|
);
|
|
356
359
|
});
|
|
357
360
|
}
|
|
@@ -515,13 +518,15 @@ function ms(arg) {
|
|
|
515
518
|
}
|
|
516
519
|
var toSecond = hs;
|
|
517
520
|
var toMillisecond = ms;
|
|
521
|
+
|
|
522
|
+
// src/date.ts
|
|
518
523
|
function timestamp() {
|
|
519
524
|
return Math.floor(Date.now() / 1e3);
|
|
520
525
|
}
|
|
521
526
|
var dayjs = _dayjs;
|
|
522
527
|
var date = dayjs;
|
|
523
528
|
function unixDate(t) {
|
|
524
|
-
return
|
|
529
|
+
return dayjs.unix(t);
|
|
525
530
|
}
|
|
526
531
|
function isDateExpired(start, end, expire) {
|
|
527
532
|
return end - start > hs(expire);
|
|
@@ -536,6 +541,217 @@ function datePeriod(start, value = 1, unit = "month") {
|
|
|
536
541
|
return unixDate(start).add(value, unit).unix();
|
|
537
542
|
}
|
|
538
543
|
|
|
544
|
+
// src/error.ts
|
|
545
|
+
var HttpStatus = /* @__PURE__ */ ((HttpStatus2) => {
|
|
546
|
+
HttpStatus2[HttpStatus2["CONTINUE"] = 100] = "CONTINUE";
|
|
547
|
+
HttpStatus2[HttpStatus2["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
|
|
548
|
+
HttpStatus2[HttpStatus2["PROCESSING"] = 102] = "PROCESSING";
|
|
549
|
+
HttpStatus2[HttpStatus2["EARLYHINTS"] = 103] = "EARLYHINTS";
|
|
550
|
+
HttpStatus2[HttpStatus2["OK"] = 200] = "OK";
|
|
551
|
+
HttpStatus2[HttpStatus2["CREATED"] = 201] = "CREATED";
|
|
552
|
+
HttpStatus2[HttpStatus2["ACCEPTED"] = 202] = "ACCEPTED";
|
|
553
|
+
HttpStatus2[HttpStatus2["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
|
|
554
|
+
HttpStatus2[HttpStatus2["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
555
|
+
HttpStatus2[HttpStatus2["RESET_CONTENT"] = 205] = "RESET_CONTENT";
|
|
556
|
+
HttpStatus2[HttpStatus2["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
|
|
557
|
+
HttpStatus2[HttpStatus2["MULTI_STATUS"] = 207] = "MULTI_STATUS";
|
|
558
|
+
HttpStatus2[HttpStatus2["ALREADY_REPORTED"] = 208] = "ALREADY_REPORTED";
|
|
559
|
+
HttpStatus2[HttpStatus2["CONTENT_DIFFERENT"] = 210] = "CONTENT_DIFFERENT";
|
|
560
|
+
HttpStatus2[HttpStatus2["AMBIGUOUS"] = 300] = "AMBIGUOUS";
|
|
561
|
+
HttpStatus2[HttpStatus2["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
|
|
562
|
+
HttpStatus2[HttpStatus2["FOUND"] = 302] = "FOUND";
|
|
563
|
+
HttpStatus2[HttpStatus2["SEE_OTHER"] = 303] = "SEE_OTHER";
|
|
564
|
+
HttpStatus2[HttpStatus2["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
|
|
565
|
+
HttpStatus2[HttpStatus2["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
|
|
566
|
+
HttpStatus2[HttpStatus2["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
|
|
567
|
+
HttpStatus2[HttpStatus2["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
568
|
+
HttpStatus2[HttpStatus2["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
569
|
+
HttpStatus2[HttpStatus2["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
|
|
570
|
+
HttpStatus2[HttpStatus2["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
571
|
+
HttpStatus2[HttpStatus2["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
572
|
+
HttpStatus2[HttpStatus2["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
|
|
573
|
+
HttpStatus2[HttpStatus2["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
|
|
574
|
+
HttpStatus2[HttpStatus2["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
|
|
575
|
+
HttpStatus2[HttpStatus2["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
|
|
576
|
+
HttpStatus2[HttpStatus2["CONFLICT"] = 409] = "CONFLICT";
|
|
577
|
+
HttpStatus2[HttpStatus2["GONE"] = 410] = "GONE";
|
|
578
|
+
HttpStatus2[HttpStatus2["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
|
|
579
|
+
HttpStatus2[HttpStatus2["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
580
|
+
HttpStatus2[HttpStatus2["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
|
|
581
|
+
HttpStatus2[HttpStatus2["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
|
|
582
|
+
HttpStatus2[HttpStatus2["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
|
|
583
|
+
HttpStatus2[HttpStatus2["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
|
|
584
|
+
HttpStatus2[HttpStatus2["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
|
|
585
|
+
HttpStatus2[HttpStatus2["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
|
|
586
|
+
HttpStatus2[HttpStatus2["MISDIRECTED"] = 421] = "MISDIRECTED";
|
|
587
|
+
HttpStatus2[HttpStatus2["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
588
|
+
HttpStatus2[HttpStatus2["LOCKED"] = 423] = "LOCKED";
|
|
589
|
+
HttpStatus2[HttpStatus2["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
|
|
590
|
+
HttpStatus2[HttpStatus2["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
|
|
591
|
+
HttpStatus2[HttpStatus2["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
|
592
|
+
HttpStatus2[HttpStatus2["UNRECOVERABLE_ERROR"] = 456] = "UNRECOVERABLE_ERROR";
|
|
593
|
+
HttpStatus2[HttpStatus2["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
594
|
+
HttpStatus2[HttpStatus2["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
|
|
595
|
+
HttpStatus2[HttpStatus2["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
|
|
596
|
+
HttpStatus2[HttpStatus2["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
597
|
+
HttpStatus2[HttpStatus2["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
598
|
+
HttpStatus2[HttpStatus2["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
599
|
+
HttpStatus2[HttpStatus2["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
|
|
600
|
+
HttpStatus2[HttpStatus2["LOOP_DETECTED"] = 508] = "LOOP_DETECTED";
|
|
601
|
+
return HttpStatus2;
|
|
602
|
+
})(HttpStatus || {});
|
|
603
|
+
var HttpError = class extends Error {
|
|
604
|
+
constructor(message, { status, code, errors }) {
|
|
605
|
+
super(message);
|
|
606
|
+
this.name = "HttpError";
|
|
607
|
+
Object.defineProperty(this, "status", {
|
|
608
|
+
value: status ?? 500 /* INTERNAL_SERVER_ERROR */,
|
|
609
|
+
writable: false,
|
|
610
|
+
enumerable: true,
|
|
611
|
+
configurable: false
|
|
612
|
+
});
|
|
613
|
+
Object.defineProperty(this, "code", {
|
|
614
|
+
value: code || "HTTP_ERROR",
|
|
615
|
+
writable: false,
|
|
616
|
+
enumerable: true,
|
|
617
|
+
configurable: false
|
|
618
|
+
});
|
|
619
|
+
Object.defineProperty(this, "errors", {
|
|
620
|
+
value: errors,
|
|
621
|
+
writable: false,
|
|
622
|
+
enumerable: true,
|
|
623
|
+
configurable: false
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
getStatus() {
|
|
627
|
+
return this.status;
|
|
628
|
+
}
|
|
629
|
+
getCode() {
|
|
630
|
+
return this.code;
|
|
631
|
+
}
|
|
632
|
+
getErrors() {
|
|
633
|
+
return this.errors;
|
|
634
|
+
}
|
|
635
|
+
toJSON() {
|
|
636
|
+
return {
|
|
637
|
+
status: this.status,
|
|
638
|
+
code: this.code,
|
|
639
|
+
message: this.message,
|
|
640
|
+
errors: this.errors
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
var BadGatewayError = class extends HttpError {
|
|
645
|
+
constructor(message = "Bad Gateway", code = "BAD_GATEWAY", errors) {
|
|
646
|
+
super(message, { status: 502 /* BAD_GATEWAY */, code, errors });
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
var BadRequestError = class extends HttpError {
|
|
650
|
+
constructor(message = "Bad Request", code = "BAD_REQUEST", errors) {
|
|
651
|
+
super(message, { status: 400 /* BAD_REQUEST */, code, errors });
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
var ConflictError = class extends HttpError {
|
|
655
|
+
constructor(message = "Conflict", code = "CONFLICT", errors) {
|
|
656
|
+
super(message, { status: 409 /* CONFLICT */, code, errors });
|
|
657
|
+
}
|
|
658
|
+
};
|
|
659
|
+
var ForbiddenError = class extends HttpError {
|
|
660
|
+
constructor(message = "Forbidden", code = "FORBIDDEN", errors) {
|
|
661
|
+
super(message, { status: 403 /* FORBIDDEN */, code, errors });
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
var TooManyRequestsError = class extends HttpError {
|
|
665
|
+
constructor(message = "Too Many Requests", code = "TOO_MANY_REQUESTS", errors) {
|
|
666
|
+
super(message, { status: 429 /* TOO_MANY_REQUESTS */, code, errors });
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
var GatewayTimeoutError = class extends HttpError {
|
|
670
|
+
constructor(message = "Gateway Timeout", code = "GATEWAY_TIMEOUT", errors) {
|
|
671
|
+
super(message, { status: 504 /* GATEWAY_TIMEOUT */, code, errors });
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
var GoneError = class extends HttpError {
|
|
675
|
+
constructor(message = "Gone", code = "GONE", errors) {
|
|
676
|
+
super(message, { status: 410 /* GONE */, code, errors });
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
var HttpVersionNotSupportedError = class extends HttpError {
|
|
680
|
+
constructor(message = "HTTP Version Not Supported", code = "HTTP_VERSION_NOT_SUPPORTED", errors) {
|
|
681
|
+
super(message, { status: 505 /* HTTP_VERSION_NOT_SUPPORTED */, code, errors });
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
var ImATeapotError = class extends HttpError {
|
|
685
|
+
constructor(message = "I'm a teapot", code = "I_AM_A_TEAPOT", errors) {
|
|
686
|
+
super(message, { status: 418 /* I_AM_A_TEAPOT */, code, errors });
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
var InternalServerError = class extends HttpError {
|
|
690
|
+
constructor(message = "Internal Server Error", code = "INTERNAL_SERVER_ERROR", errors) {
|
|
691
|
+
super(message, { status: 500 /* INTERNAL_SERVER_ERROR */, code, errors });
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
var MethodNotAllowedError = class extends HttpError {
|
|
695
|
+
constructor(message = "Method Not Allowed", code = "METHOD_NOT_ALLOWED", errors) {
|
|
696
|
+
super(message, { status: 405 /* METHOD_NOT_ALLOWED */, code, errors });
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
var MisdirectedError = class extends HttpError {
|
|
700
|
+
constructor(message = "Misdirected Request", code = "MISDIRECTED", errors) {
|
|
701
|
+
super(message, { status: 421 /* MISDIRECTED */, code, errors });
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
var NotAcceptableError = class extends HttpError {
|
|
705
|
+
constructor(message = "Not Acceptable", code = "NOT_ACCEPTABLE", errors) {
|
|
706
|
+
super(message, { status: 406 /* NOT_ACCEPTABLE */, code, errors });
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
var NotFoundError = class extends HttpError {
|
|
710
|
+
constructor(message = "Not Found", code = "NOT_FOUND", errors) {
|
|
711
|
+
super(message, { status: 404 /* NOT_FOUND */, code, errors });
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
var NotImplementedError = class extends HttpError {
|
|
715
|
+
constructor(message = "Not Implemented", code = "NOT_IMPLEMENTED", errors) {
|
|
716
|
+
super(message, { status: 501 /* NOT_IMPLEMENTED */, code, errors });
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
var PayloadTooLargeError = class extends HttpError {
|
|
720
|
+
constructor(message = "Payload Too Large", code = "PAYLOAD_TOO_LARGE", errors) {
|
|
721
|
+
super(message, { status: 413 /* PAYLOAD_TOO_LARGE */, code, errors });
|
|
722
|
+
}
|
|
723
|
+
};
|
|
724
|
+
var PreconditionFailedError = class extends HttpError {
|
|
725
|
+
constructor(message = "Precondition Failed", code = "PRECONDITION_FAILED", errors) {
|
|
726
|
+
super(message, { status: 412 /* PRECONDITION_FAILED */, code, errors });
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
var RequestTimeoutError = class extends HttpError {
|
|
730
|
+
constructor(message = "Request Timeout", code = "REQUEST_TIMEOUT", errors) {
|
|
731
|
+
super(message, { status: 408 /* REQUEST_TIMEOUT */, code, errors });
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
var ServiceUnavailableError = class extends HttpError {
|
|
735
|
+
constructor(message = "Service Unavailable", code = "SERVICE_UNAVAILABLE", errors) {
|
|
736
|
+
super(message, { status: 503 /* SERVICE_UNAVAILABLE */, code, errors });
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
var UnauthorizedError = class extends HttpError {
|
|
740
|
+
constructor(message = "Unauthorized", code = "UNAUTHORIZED", errors) {
|
|
741
|
+
super(message, { status: 401 /* UNAUTHORIZED */, code, errors });
|
|
742
|
+
}
|
|
743
|
+
};
|
|
744
|
+
var UnprocessableEntityError = class extends HttpError {
|
|
745
|
+
constructor(message = "Unprocessable Entity", code = "UNPROCESSABLE_ENTITY", errors) {
|
|
746
|
+
super(message, { status: 422 /* UNPROCESSABLE_ENTITY */, code, errors });
|
|
747
|
+
}
|
|
748
|
+
};
|
|
749
|
+
var UnsupportedMediaTypeError = class extends HttpError {
|
|
750
|
+
constructor(message = "Unsupported Media Type", code = "UNSUPPORTED_MEDIA_TYPE", errors) {
|
|
751
|
+
super(message, { status: 415 /* UNSUPPORTED_MEDIA_TYPE */, code, errors });
|
|
752
|
+
}
|
|
753
|
+
};
|
|
754
|
+
|
|
539
755
|
// src/mime-db.json
|
|
540
756
|
var mime_db_default = {
|
|
541
757
|
"123": "application/vnd.lotus-1-2-3",
|
|
@@ -1807,15 +2023,23 @@ function excludeObject(target, excludes = []) {
|
|
|
1807
2023
|
return pickObject(target, [], excludes);
|
|
1808
2024
|
}
|
|
1809
2025
|
function pickValidValues(target, fields) {
|
|
2026
|
+
if (!isObject(target) || !isArray(fields)) {
|
|
2027
|
+
return {};
|
|
2028
|
+
}
|
|
1810
2029
|
const dist = {};
|
|
1811
2030
|
fields.forEach((field) => {
|
|
1812
2031
|
let key = String(field);
|
|
1813
2032
|
let alias;
|
|
1814
2033
|
if (isArray(field)) {
|
|
2034
|
+
if (field.length === 0 || isNil(field[0])) {
|
|
2035
|
+
return;
|
|
2036
|
+
}
|
|
1815
2037
|
key = field[0];
|
|
1816
|
-
if (field.length > 1) {
|
|
1817
|
-
alias = field[1];
|
|
2038
|
+
if (field.length > 1 && !isNil(field[1])) {
|
|
2039
|
+
alias = String(field[1]);
|
|
1818
2040
|
}
|
|
2041
|
+
} else if (isNil(field)) {
|
|
2042
|
+
return;
|
|
1819
2043
|
}
|
|
1820
2044
|
let value = target[key];
|
|
1821
2045
|
if (isValid(value)) {
|
|
@@ -1843,16 +2067,22 @@ function removeObjectNil(target) {
|
|
|
1843
2067
|
return newObj;
|
|
1844
2068
|
}
|
|
1845
2069
|
function copyObjectValues(target, dist, keyMaps) {
|
|
1846
|
-
if (!isObject(target) || !isObject(dist)) {
|
|
2070
|
+
if (!isObject(target) || !isObject(dist) || !isArray(keyMaps)) {
|
|
1847
2071
|
return;
|
|
1848
2072
|
}
|
|
1849
2073
|
for (const keys of keyMaps) {
|
|
1850
2074
|
let targetKey;
|
|
1851
2075
|
let distKey;
|
|
1852
2076
|
if (isArray(keys)) {
|
|
1853
|
-
|
|
1854
|
-
|
|
2077
|
+
if (keys.length === 0 || isNil(keys[0])) {
|
|
2078
|
+
continue;
|
|
2079
|
+
}
|
|
2080
|
+
targetKey = String(keys[0]);
|
|
2081
|
+
distKey = !isNil(keys[1]) ? String(keys[1]) : targetKey;
|
|
1855
2082
|
} else {
|
|
2083
|
+
if (isNil(keys)) {
|
|
2084
|
+
continue;
|
|
2085
|
+
}
|
|
1856
2086
|
targetKey = String(keys);
|
|
1857
2087
|
distKey = targetKey;
|
|
1858
2088
|
}
|
|
@@ -1867,52 +2097,29 @@ function copyObjectValues(target, dist, keyMaps) {
|
|
|
1867
2097
|
}
|
|
1868
2098
|
|
|
1869
2099
|
// src/random.ts
|
|
1870
|
-
var
|
|
1871
|
-
var
|
|
1872
|
-
var
|
|
1873
|
-
var
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
RandomType2[RandomType2["UPPER"] = 1] = "UPPER";
|
|
1878
|
-
RandomType2[RandomType2["NUMERIC"] = 2] = "NUMERIC";
|
|
1879
|
-
RandomType2[RandomType2["HEXIC"] = 3] = "HEXIC";
|
|
1880
|
-
RandomType2[RandomType2["LOWER_NUMERIC"] = 4] = "LOWER_NUMERIC";
|
|
1881
|
-
RandomType2[RandomType2["UPPER_NUMERIC"] = 5] = "UPPER_NUMERIC";
|
|
1882
|
-
RandomType2[RandomType2["ALPHANUMERIC"] = 6] = "ALPHANUMERIC";
|
|
1883
|
-
return RandomType2;
|
|
1884
|
-
})(RandomType || {});
|
|
1885
|
-
function random(len = length * 2, type2 = 6 /* ALPHANUMERIC */) {
|
|
1886
|
-
let alphabet = numeric + lower + upper;
|
|
1887
|
-
switch (type2) {
|
|
1888
|
-
case 0 /* LOWER */:
|
|
1889
|
-
alphabet = lower;
|
|
1890
|
-
break;
|
|
1891
|
-
case 1 /* UPPER */:
|
|
1892
|
-
alphabet = upper;
|
|
1893
|
-
break;
|
|
1894
|
-
case 3 /* HEXIC */:
|
|
1895
|
-
alphabet = hexic;
|
|
1896
|
-
break;
|
|
1897
|
-
case 2 /* NUMERIC */:
|
|
1898
|
-
alphabet = numeric;
|
|
1899
|
-
break;
|
|
1900
|
-
case 4 /* LOWER_NUMERIC */:
|
|
1901
|
-
alphabet = lower + numeric;
|
|
1902
|
-
break;
|
|
1903
|
-
case 5 /* UPPER_NUMERIC */:
|
|
1904
|
-
alphabet = upper + numeric;
|
|
1905
|
-
break;
|
|
1906
|
-
case 6 /* ALPHANUMERIC */:
|
|
1907
|
-
alphabet = lower + upper + numeric;
|
|
1908
|
-
break;
|
|
1909
|
-
}
|
|
1910
|
-
let str = "";
|
|
1911
|
-
const alphabetLength = alphabet.length;
|
|
2100
|
+
var NUMERIC = "0123456789";
|
|
2101
|
+
var HEXIC = "0123456789abcdef";
|
|
2102
|
+
var ALPHA = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
2103
|
+
var ALPHANUMERIC = ALPHA + NUMERIC;
|
|
2104
|
+
function random(len = 6, alphabet = ALPHANUMERIC) {
|
|
2105
|
+
let result = "";
|
|
2106
|
+
const length = alphabet.length;
|
|
1912
2107
|
for (let i = 0; i < len; i++) {
|
|
1913
|
-
|
|
2108
|
+
result += alphabet.charAt(Math.floor(Math.random() * length));
|
|
1914
2109
|
}
|
|
1915
|
-
return
|
|
2110
|
+
return result;
|
|
2111
|
+
}
|
|
2112
|
+
function randomHexic(len) {
|
|
2113
|
+
return random(len, HEXIC);
|
|
2114
|
+
}
|
|
2115
|
+
function randomAlpha(len) {
|
|
2116
|
+
return random(len, ALPHA);
|
|
2117
|
+
}
|
|
2118
|
+
function randomNumeric(len) {
|
|
2119
|
+
return random(len, NUMERIC);
|
|
2120
|
+
}
|
|
2121
|
+
function randomNumber(min, max) {
|
|
2122
|
+
return Math.ceil(Math.random() * (max - min) + min);
|
|
1916
2123
|
}
|
|
1917
2124
|
function slugify(text, options) {
|
|
1918
2125
|
return slug(text, {
|
|
@@ -1922,6 +2129,6 @@ function slugify(text, options) {
|
|
|
1922
2129
|
});
|
|
1923
2130
|
}
|
|
1924
2131
|
|
|
1925
|
-
export { FILE_MIME_TYPES, IMAGE_MIME_TYPES,
|
|
1926
|
-
//# sourceMappingURL=
|
|
2132
|
+
export { BadGatewayError, BadRequestError, ConflictError, FILE_MIME_TYPES, ForbiddenError, GatewayTimeoutError, GoneError, HttpError, HttpStatus, HttpVersionNotSupportedError, IMAGE_MIME_TYPES, ImATeapotError, InternalServerError, MethodNotAllowedError, MisdirectedError, NotAcceptableError, NotFoundError, NotImplementedError, PayloadTooLargeError, PreconditionFailedError, RequestTimeoutError, ServiceUnavailableError, TooManyRequestsError, UnauthorizedError, UnprocessableEntityError, UnsupportedMediaTypeError, alpha, alphaHexToRgb, bytes, clone, clsx, colorBrightness, commonFileMimeTypes, commonImageMimeTypes, copyObjectValues, darken, date, datePeriod, dayjs, excludeObject, 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, random, randomAlpha, randomHexic, randomNumber, randomNumeric, removeObjectNil, rgbToHex, slugify, timestamp, toBool, toDuration, toFixed, toFloat, toInt, toInteger, toIntlNumber, toJSON, toMillisecond, toSecond, toURLParams, toURLQuery, type, unixDate, unixDiff };
|
|
2133
|
+
//# sourceMappingURL=index.mjs.map
|
|
1927
2134
|
//# sourceMappingURL=index.mjs.map
|