mirror of
https://github.com/certd/certd.git
synced 2026-04-24 04:17:25 +08:00
feat: 站点个性化设置
This commit is contained in:
@@ -16,6 +16,8 @@ import { promises } from "./util.promise.js";
|
||||
import { fileUtils } from "./util.file.js";
|
||||
import _ from "lodash-es";
|
||||
import { cache } from "./util.cache.js";
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
export const utils = {
|
||||
sleep,
|
||||
http,
|
||||
@@ -27,4 +29,5 @@ export const utils = {
|
||||
mergeUtils,
|
||||
cache,
|
||||
nanoid,
|
||||
dayjs
|
||||
};
|
||||
|
||||
@@ -25,7 +25,26 @@ export function safePromise<T>(callback: (resolve: (ret: T) => void, reject: (re
|
||||
});
|
||||
}
|
||||
|
||||
export function promisify(func: any) {
|
||||
return function (...args: any) {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
func(...args, (err: any, data: any) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const promises = {
|
||||
TimeoutPromise,
|
||||
safePromise,
|
||||
promisify,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user