mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: add hydrooj uninstall command
This commit is contained in:
1 parent
d21ae767dd
commit
bd1034eff8
3 files changed
+47
-29
No files matched your search
@@ -126,6 +126,36 @@ Set.intersection = function Intersection<T>(A: Set<T> | Array<T> = [], B: Set<T>
|
||||
return intersection;
|
||||
};
|
||||
|
||||
export function sleep(timeout: number) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => resolve(true), timeout);
|
||||
});
|
||||
}
|
||||
|
||||
function deepen(modifyString: (source: string) => string) {
|
||||
function modifyObject<T>(source: T): T {
|
||||
if (typeof source !== 'object' || !source) return source;
|
||||
if (Array.isArray(source)) return source.map(modifyObject) as any;
|
||||
const result = {} as T;
|
||||
for (const key in source) {
|
||||
result[modifyString(key)] = modifyObject(source[key]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return function t<T>(source: T): T {
|
||||
if (typeof source === 'string') return modifyString(source) as any;
|
||||
return modifyObject(source);
|
||||
};
|
||||
}
|
||||
|
||||
export function noop() { }
|
||||
|
||||
export const camelCase = deepen((source) => source.replace(/[_-][a-z]/g, (str) => str.slice(1).toUpperCase()));
|
||||
export const paramCase = deepen((source) => source.replace(/_/g, '-').replace(/(?<!^)[A-Z]/g, (str) => `-${str.toLowerCase()}`));
|
||||
export const snakeCase = deepen((source) => source.replace(/-/g, '_').replace(/(?<!^)[A-Z]/g, (str) => `_${str.toLowerCase()}`));
|
||||
|
||||
|
||||
const TIME_RE = /^([0-9]+(?:\.[0-9]*)?)([mu]?)s?$/i;
|
||||
const TIME_UNITS = { '': 1000, m: 1, u: 0.001 };
|
||||
const MEMORY_RE = /^([0-9]+(?:\.[0-9]*)?)([kmg])b?$/i;
|
||||
|
||||
Reference in new issue
Block a user