@jiakun-zhao/utils 1.4.1 → 1.4.2
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 +7 -7
- package/dist/index.mjs +6 -6
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
//#region src/
|
|
1
|
+
//#region src/addons/assert.d.ts
|
|
2
2
|
declare function assert(condition: boolean, message: string): asserts condition;
|
|
3
3
|
//#endregion
|
|
4
|
-
//#region src/
|
|
4
|
+
//#region src/addons/deep-equal.d.ts
|
|
5
5
|
declare function isDeepEqual(a: any, b: any): boolean;
|
|
6
6
|
//#endregion
|
|
7
|
-
//#region src/
|
|
7
|
+
//#region src/addons/http-status-code.d.ts
|
|
8
8
|
declare const status: {
|
|
9
9
|
readonly 100: "Continue";
|
|
10
10
|
readonly 101: "Switching Protocols";
|
|
@@ -72,10 +72,10 @@ declare const status: {
|
|
|
72
72
|
};
|
|
73
73
|
declare function getHttpStatusMessage(code: keyof typeof status): "Continue" | "Switching Protocols" | "Processing" | "Early Hints" | "OK" | "Created" | "Accepted" | "Non-Authoritative Information" | "No Content" | "Reset Content" | "Partial Content" | "Multi-Status" | "Already Reported" | "IM Used" | "Multiple Choices" | "Moved Permanently" | "Found" | "See Other" | "Not Modified" | "Use Proxy" | "Temporary Redirect" | "Permanent Redirect" | "Bad Request" | "Unauthorized" | "Payment Required" | "Forbidden" | "Not Found" | "Method Not Allowed" | "Not Acceptable" | "Proxy Authentication Required" | "Request Timeout" | "Conflict" | "Gone" | "Length Required" | "Precondition Failed" | "Payload Too Large" | "URI Too Long" | "Unsupported Media Type" | "Range Not Satisfiable" | "Expectation Failed" | "I'm a Teapot" | "Misdirected Request" | "Unprocessable Entity" | "Locked" | "Failed Dependency" | "Too Early" | "Upgrade Required" | "Precondition Required" | "Too Many Requests" | "Request Header Fields Too Large" | "Unavailable For Legal Reasons" | "Internal Server Error" | "Not Implemented" | "Bad Gateway" | "Service Unavailable" | "Gateway Timeout" | "HTTP Version Not Supported" | "Variant Also Negotiates" | "Insufficient Storage" | "Loop Detected" | "Bandwidth Limit Exceeded" | "Not Extended" | "Network Authentication Required";
|
|
74
74
|
//#endregion
|
|
75
|
-
//#region src/
|
|
75
|
+
//#region src/addons/natural-compare.d.ts
|
|
76
76
|
declare function naturalCompare<T extends string | number>(a: T, b: T): -1 | 0 | 1;
|
|
77
77
|
//#endregion
|
|
78
|
-
//#region src/
|
|
78
|
+
//#region src/addons/promise.d.ts
|
|
79
79
|
type Awaitable<T> = T | PromiseLike<T>;
|
|
80
80
|
//#endregion
|
|
81
81
|
//#region src/base/array.d.ts
|
|
@@ -135,8 +135,8 @@ declare const isRegExp: (val: any) => val is RegExp;
|
|
|
135
135
|
declare const toString: (val: any) => string;
|
|
136
136
|
declare const isString: (val: unknown) => val is string;
|
|
137
137
|
declare const slash: (str: string) => string;
|
|
138
|
-
declare const ensurePrefix: (
|
|
139
|
-
declare const ensureSuffix: (
|
|
138
|
+
declare const ensurePrefix: (str: string, prefix: string) => string;
|
|
139
|
+
declare const ensureSuffix: (str: string, suffix: string) => string;
|
|
140
140
|
declare const capitalize: (str: string) => string;
|
|
141
141
|
//#endregion
|
|
142
142
|
export { Arrayable, Awaitable, ElementOf, Fn, Nullable, assert, capitalize, clamp, clearUndefined, createArray, ensurePrefix, ensureSuffix, getHttpStatusMessage, isArray, isBoolean, isDate, isDeepEqual, isDefined, isFunction, isKeyOf, isNull, isNumber, isObject, isRegExp, isSameDay, isString, isToDay, isTruthy, isUndefined, lerp, naturalCompare, noop, notNull, notNullish, notUndefined, objectFilter, objectOmit, objectPick, range, shuffle, singleOrNull, slash, status, timestamp, toArray, toString, transform, uniq };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
//#region src/
|
|
1
|
+
//#region src/addons/assert.ts
|
|
2
2
|
function assert(condition, message) {
|
|
3
3
|
if (!condition) throw new Error(message);
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
//#endregion
|
|
7
|
-
//#region src/
|
|
7
|
+
//#region src/addons/deep-equal.ts
|
|
8
8
|
function isDeepEqual(a, b) {
|
|
9
9
|
if (a === b) return true;
|
|
10
10
|
const constructor = a?.constructor;
|
|
@@ -21,7 +21,7 @@ function isDeepEqual(a, b) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
//#endregion
|
|
24
|
-
//#region src/
|
|
24
|
+
//#region src/addons/http-status-code.ts
|
|
25
25
|
const status = {
|
|
26
26
|
100: "Continue",
|
|
27
27
|
101: "Switching Protocols",
|
|
@@ -92,7 +92,7 @@ function getHttpStatusMessage(code) {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
//#endregion
|
|
95
|
-
//#region src/
|
|
95
|
+
//#region src/addons/natural-compare.ts
|
|
96
96
|
function naturalCompare(a, b) {
|
|
97
97
|
var i, codeA, codeB = 1, posA = 0, posB = 0, alphabet = String.alphabet;
|
|
98
98
|
function getCode(str, pos, code) {
|
|
@@ -149,8 +149,8 @@ const isBoolean = (val) => typeof val === "boolean";
|
|
|
149
149
|
const toString = (val) => Object.prototype.toString.call(val);
|
|
150
150
|
const isString = (val) => typeof val === "string";
|
|
151
151
|
const slash = (str) => str.replace(/\\/g, "/");
|
|
152
|
-
const ensurePrefix = (
|
|
153
|
-
const ensureSuffix = (
|
|
152
|
+
const ensurePrefix = (str, prefix) => str.startsWith(prefix) ? str : prefix + str;
|
|
153
|
+
const ensureSuffix = (str, suffix) => str.endsWith(suffix) ? str : str + suffix;
|
|
154
154
|
const capitalize = (str) => str[0].toUpperCase() + str.slice(1).toLowerCase();
|
|
155
155
|
|
|
156
156
|
//#endregion
|