mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
使用export = 替换export default
This commit is contained in:
1 parent
12af2f7542
commit
c63643d349
15 files changed
+38
-25
No files matched your search
@@ -11,9 +11,11 @@ async function _download(url: string, path: string, retry: number) {
|
||||
return path;
|
||||
}
|
||||
|
||||
export default function download(url: string, path?: string, retry = 3) {
|
||||
function download(url: string, path?: string, retry = 3) {
|
||||
if (path) return _download(url, path, retry);
|
||||
return superagent.get(url).retry(retry);
|
||||
}
|
||||
|
||||
export = download;
|
||||
|
||||
global.Hydro.lib.download = download;
|
||||
@@ -1,7 +1,9 @@
|
||||
import crypto from 'crypto';
|
||||
|
||||
export default function hash(password: string, salt: string) {
|
||||
function hash(password: string, salt: string) {
|
||||
return crypto.pbkdf2Sync(password, salt, 100000, 64, 'sha256').toString('hex').substr(0, 64);
|
||||
}
|
||||
|
||||
export = hash;
|
||||
|
||||
global.Hydro.lib['hash.hydro'] = hash;
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Dictionary } from 'lodash';
|
||||
|
||||
const locales = {};
|
||||
|
||||
declare global {
|
||||
@@ -45,12 +47,14 @@ String.prototype.translate = function translate(...languages: string[]) {
|
||||
return this;
|
||||
};
|
||||
|
||||
export default function load(data) {
|
||||
function load(data: Dictionary<string>) {
|
||||
for (const i in data) {
|
||||
if (!locales[i]) locales[i] = data[i];
|
||||
else locales[i] = Object.assign(locales[i], data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
export = load;
|
||||
|
||||
global.Hydro.locales = locales;
|
||||
global.Hydro.lib.i18n = load;
|
||||
@@ -38,4 +38,4 @@ const exp = new Logger();
|
||||
|
||||
global.Hydro.lib.logger = exp;
|
||||
|
||||
export default exp;
|
||||
export = exp;
|
||||
@@ -130,8 +130,9 @@ function rstr2hex(input) {
|
||||
return output;
|
||||
}
|
||||
|
||||
export default function md5(s: string) {
|
||||
function md5(s: string) {
|
||||
return rstr2hex(rstrMD5(unescape(encodeURIComponent(s))));
|
||||
}
|
||||
|
||||
export = md5;
|
||||
global.Hydro.lib.md5 = md5;
|
||||
@@ -54,4 +54,4 @@ Item('domain_dashboard', null, 'domain', PERM.PERM_EDIT_DOMAIN);
|
||||
Item('manage_dashboard', null, 'manage', PRIV.PRIV_EDIT_SYSTEM);
|
||||
|
||||
global.Hydro.lib.nav = Item;
|
||||
export default Item;
|
||||
export = Item;
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Cursor } from 'mongodb';
|
||||
import { ValidationError } from '../error';
|
||||
|
||||
export default async function paginate(
|
||||
async function paginate(
|
||||
cursor: Cursor, page: number, pageSize: number,
|
||||
): Promise<[any[]/* docs */, number/* numPages */, number/* count */]> {
|
||||
if (page <= 0) throw new ValidationError('page');
|
||||
@@ -13,4 +13,6 @@ export default async function paginate(
|
||||
return [pageDocs, numPages, count];
|
||||
}
|
||||
|
||||
export = paginate;
|
||||
|
||||
global.Hydro.lib.paginate = paginate;
|
||||
@@ -11,4 +11,4 @@ function* ranked<T>(diter: T[], equ = (a: T, b: T) => a === b): Generator<[numbe
|
||||
}
|
||||
|
||||
global.Hydro.lib.rank = ranked;
|
||||
export default ranked;
|
||||
export = ranked;
|
||||
@@ -107,7 +107,7 @@ interface RatingOutputUser {
|
||||
uid: number,
|
||||
}
|
||||
|
||||
export default function calculate(users: RatingInputUser[]): RatingOutputUser[] {
|
||||
function calculate(users: RatingInputUser[]): RatingOutputUser[] {
|
||||
let last_idx = 0;
|
||||
let last_rank = 1;
|
||||
for (let i = 1; i < users.length; i++) {
|
||||
@@ -124,4 +124,6 @@ export default function calculate(users: RatingInputUser[]): RatingOutputUser[]
|
||||
return calculator.calculate() as RatingOutputUser[];
|
||||
}
|
||||
|
||||
export = calculate;
|
||||
|
||||
global.Hydro.lib.rating = calculate;
|
||||
@@ -7,4 +7,4 @@ function sha1(content: string) {
|
||||
}
|
||||
|
||||
global.Hydro.lib.sha1 = sha1;
|
||||
export default sha1;
|
||||
export = sha1;
|
||||
@@ -1,6 +1,6 @@
|
||||
import yaml from 'js-yaml';
|
||||
|
||||
export default function convert(ini: string) {
|
||||
function convert(ini: string) {
|
||||
const f = ini.split('\n');
|
||||
const count = parseInt(f[0], 10);
|
||||
const res = { cases: [] };
|
||||
@@ -30,3 +30,4 @@ export default function convert(ini: string) {
|
||||
}
|
||||
|
||||
global.Hydro.lib['testdata.convert.ini'] = convert;
|
||||
export = convert;
|
||||
Reference in new issue
Block a user