UNPKG

@ovine/core

Version:

Build flexible admin system with json.

48 lines (47 loc) 2.3 kB
/// <reference types="react" /> import * as Types from "./types"; /** * 从数组中随机抽取一个 * @param source 参数数组 */ export declare const choice: (source: any[]) => any; export declare function isExpired(expiredTime: string | number, baseTime?: number): boolean; /** * 解析 querystring 为 json 格式数据 * @param key 需要获取的数据 json[key], 不传为整个json * @param url 待解析的url 默认为location.href */ export declare function getUrlParams(key?: string, url?: string): any | undefined; /** * 重试异步操作, 主要用于网络异常,导致文件找不到报错 load chunk error * @param promiseFn 需要异步操作部分 * @param retriesLeft 最多尝试的次数, 默认5次 * @param interval 重试间隔,默认间隔1.5秒 */ export declare function retryPromise<T>(promiseFn: () => Promise<T>, retriesLeft?: number, interval?: number): Promise<T>; /** * 是否是子串 * @param source 模版字符串 * @param check 待检验字符串 * @param pos 需要校验的子串位置 */ export declare function isSubStr(source: string, check: string, pos?: number): boolean; export declare function cls(...args: any[]): string; export declare function promisedTimeout(ms: number): Promise<unknown>; export declare function json2reactFactory(mapper: Types.ObjectOf<any> | ((type: string, props?: any) => any)): (entrySchema: string | number | any[] | { [prop: string]: any; type: string; children?: any; }) => ((schema: any, key?: any) => string | number | import("react").ReactElement<{}, string | import("react").JSXElementConstructor<any>> | null) | (string | number | import("react").ReactElement<{}, string | import("react").JSXElementConstructor<any>> | null)[]; export declare function loadScriptAsync(src: string, async?: boolean): Promise<unknown>; declare type SerializeOption = { space: number; isJSON: boolean; unsafe: boolean; ignoreFunction: boolean; }; export declare function serialize(source: object, option?: Partial<SerializeOption>): string; export declare function deserialize(source?: string): any; export declare function rmUrlRepeatSlant(url: string): string; export declare function str2function(name: string, content: string, ...args: Array<string>): Function | null; export {};