export * from "./base64"; /** 雪花算法获取id */ export declare class Genid { private BaseTime; private WorkerId; private WorkerIdBitLength; private SeqBitLength; private MaxSeqNumber; private MinSeqNumber; private TopOverCostCount; private _TimestampShift; private _CurrentSeqNumber; private _LastTimeTick; private _TurnBackTimeTick; private _TurnBackIndex; private _IsOverCost; private _OverCostCountInOneTerm; /** *Creates an instance of Genid. * @author bubao * @param {{ * Method: 1, // 雪花计算方法,(1-漂移算法|2-传统算法),默认 1 * BaseTime: 1577836800000, // 基础时间(ms 单位),不能超过当前系统时间 * WorkerId: Number, // 机器码,必须由外部设定,最大值 2^WorkerIdBitLength-1 * WorkerIdBitLength: 6, // 机器码位长,默认值 6,取值范围 [1, 15](要求:序列数位长+机器码位长不超过 22) * SeqBitLength: 6, // 序列数位长,默认值 6,取值范围 [3, 21](要求:序列数位长+机器码位长不超过 22) * MaxSeqNumber: 5, // 最大序列数(含),设置范围 [MinSeqNumber, 2^SeqBitLength-1],默认值 0,表示最大序列数取最大值(2^SeqBitLength-1]) * MinSeqNumber: 5, // 最小序列数(含),默认值 5,取值范围 [5, MaxSeqNumber],每毫秒的前 5 个序列数对应编号 0-4 是保留位,其中 1-4 是时间回拨相应预留位,0 是手工新值预留位 * TopOverCostCount: 2000// 最大漂移次数(含),默认 2000,推荐范围 500-10000(与计算能力有关) * }} options * @memberof Genid */ constructor(options?: GenidOptions); NextOverCostId(): bigint; NextNormalId(): bigint; private CalcId; private CalcTurnBackId; private GetCurrentTimeTick; private GetNextTimeTick; NextId(): number; get id(): number; } export declare const iyq = 1000, /** 雪花算法Genid的实体 */ unid: Genid, /** number string 的数组 */ nsa: readonly ["number", "string"], /** 基础数据类型的数组 */ basics: readonly ["string", "number", "bigint", "boolean", "symbol", "undefined", "function", "null", "date"], /** 一天的秒数 */ daySeconds = 86400, /** 一天的微秒 */ dayMilliseconds = 86400000, /** 默认时间 2020-01-01 00:00:00 */ defDate: Date, mimeType: { readonly html: readonly ["html", "htm", "shtml"]; readonly text: readonly ["css", "xml", "mml", "txt", "jad", "wml", "htc"]; readonly img: readonly ["xbm", "tif", "jfif", "ico", "tiff", "gif", "svg", "jpeg", "svgz", "jpg", "webp", "png", "bmp", "pjp", "apng", "pjpeg", "avif", "wbmp", "jng"]; readonly audio: readonly ["mid", "midi", "kar", "mp3", "ogg", "m4a", "ra", "aac"]; readonly video: readonly ["3gpp", "3gp", "mp4", "mpeg", "mpg", "mov", "webm", "flv", "m4v", "mng", "asf", "wmv", "avi"]; readonly tjs: readonly ["js", "mjs"]; }, cache: { [k: string]: { t: number; d: any; c: { resolve: cbk; reject: cbk; }[]; }; }, ncs: cbk[], bus: Array<(time: number) => Promise>; export type Basics = (typeof basics)[number]; export type Ns = typeof nsa[number]; export declare function next(pf?: any): Promise; /** 当前没有缓存 返回tru,表示新增加了一个等待队列 */ export declare function addCache(md5: string, resolve: cbk, reject: cbk, timeout?: number): boolean; export declare function execCache(md5: string, data: any, isReject?: any, timeout?: number): void; /** obj类型的数据比较,相等返回true; 当sure为false时,只要v1里对应key的值等于v2对应的值,则返回true; 当sure为false时,需要二者完全相等 */ export declare function objCompare(v1: any, v2: any, sure?: any): boolean; export declare function cmpObj(v1: any, v2: any): boolean; /** 取对象不同属性;只判定一层,不进行深度判定,值不一致时则返回dist对应key * @param source 比较源 * @param dist 比较值 * @param isdist 是否以dist的key进行比较 * @returns 比较出现不同返回不同的字段,否则返回空 */ export declare function objDiff(source?: obj, dist?: obj, isdist?: any): undefined | obj; /** 从数组中查找符合条件的数据; * @param {Array} arr 需要查找的数组 * @param {Partial} val 待查找的数据 * @param {T[Key]} retKey 返回数据字段 * @param {any} whole 待查找的数据是否完全与数组的数据匹配 * @returns {((Key) | T)[] | undefined} 返回查找内容 */ export declare function arrFind>(arr: Array, val: Partial, retKey: K, whole?: any): T[K][] | undefined; export declare function arrFind(arr: Array, val: Partial, retKey?: Key, whole?: any): T[] | undefined; /** 简化的arrFind * @param {Array} arr 需要查找的数组 * @param {Partial} val 待查找的数据 * @param {any} index 是否返回查找的数据下标 * @returns {number | T | undefined} 返回查找内容 */ export declare function arrFind2(arr: Array, val: Partial): T | undefined; export declare function arrFind2(arr: Array, val: Partial, index: false): T | undefined; export declare function arrFind2(arr: Array, val: Partial, index: 0): T | undefined; export declare function arrFind2(arr: Array, val: Partial, index: ""): T | undefined; export declare function arrFind2(arr: Array, val: Partial, index: any): number | undefined; /** 查找树形数据 * @param {Tree} arr 需要查找的树形数组 * @param {T} v 待查询的元素 * @param {((el: T) => void) | undefined} callbackfn 每个便利均会运行的回调函数 * @returns {T[] | undefined} 查询结果,如果查询到 将返回结果,否则返回undefined */ export declare function findTreeValue(arr: T[], v: T, callbackfn?: (el: T) => void): T[] | undefined; export declare function getValueByPath(obj: any, path?: string): any; /** 查找树形数组 * @param arr 需要查找的数组 * @param predicate 待查找的数组成员 或 回调函数 * @param retKey 要返回的成员所在的下标; * @param callbackfn 遍历每个成员时的回调函数;如果提供的值是Function则会遍历所有成员 * @returns 查询符合条件的树形数组下标 */ export declare function findTree(arr: T[], predicate: T | ((el: T) => any), retKey: "#index", callbackfn?: (el: T) => void): number[]; /** 查找树形数组 * @param arr 需要查找的数组 * @param predicate 待查找的数组成员 或 回调函数 * @param retKey "#frist" 返回第一个符合条件的成员 * @param callbackfn 遍历每个成员时的回调函数;如果提供的值是Function则会遍历所有成员 * @returns 第一个符合条件的成员 */ export declare function findTree(arr: T[], predicate: (el: T) => any, retKey: "#frist", callbackfn?: (el: T) => void): T; /** 查找树形数组 * @param arr 需要查找的数组 * @param predicate 待查找的数组成员 或 回调函数 * @param retKey 要返回的成员属性名; * @param callbackfn 遍历每个成员时的回调函数;如果提供的值是Function则会遍历所有成员 * @returns 返回符合要求的成员属性值数组 */ export declare function findTree>(arr: T[], predicate: (el: T) => any, retKey: K, callbackfn?: (el: T) => void): Array; /** 查找树形数组 * @param arr 需要查找的数组 * @param predicate 待查找的数组成员 或 回调函数 * @param retKey 要返回的成员属性名; * @param callbackfn 遍历每个成员时的回调函数;如果提供的值是Function则会遍历所有成员 * @returns 返回符合要求的成员属性值数组 */ export declare function findTree(arr: T[], predicate: (el: T) => any, retKey?: string, callbackfn?: (el: T) => void): T[]; /** 查找树形数组 * @param arr 需要查找的数组 * @param predicate 待查找的数组成员 或 回调函数 * @param resultFormat 返回数据的格式化回调 * @param callbackfn 遍历每个成员时的回调函数;如果提供的值是Function则会遍历所有成员 * @returns 未找到符合条件的数据 返回 undefined */ export declare function findTree(arr: T[], predicate: T | ((el: T) => any), retKey?: string | ((el: T) => R), callbackfn?: (el: T) => void): R[]; /** 获取数据类型 */ export declare function type(p: any): string; /** 比较两个数据的数据类型是否相同 */ export declare function cmpType(p1: any, p2: T): p1 is typeof p2; /** 删除p的所有成员,类似p={};但是不改变p的指针 */ export declare function del(p: any): void; /** 取字符串的真实数据长度,汉字占用3个字节? */ export declare function strLen(str: string): number; /** 将树形数据格式化成数组 */ export declare function tree2arr(param?: Tree | TreeEle, idKey?: string, childrenKey?: string): Tree; /** 保持某个字段的唯一性进行 push */ export declare function pushArr(arr: Array, ele: T, idStr?: string): T[]; /** 获取树形数据的所有子成员 */ export declare function getTreeChildrens(c: Tree, idStr?: string): Tree; export declare function getChildrens(c?: TreeEle, key?: string): any[]; /** 数组到树形数据 */ export declare function arr2tree(arr: T[], idStr?: string, pidStr?: string, init?: any): Tree; /** 获取id为参数id的属性数据的所有子成员id */ export declare function getTreeID(tree: Array, id: T, key?: string): T[]; /** 安全的 JSON.parse */ export declare function strParse(p: any, def?: T): T; /** 根据 key只的属性 进行 join组合 */ export declare function kJoin(arr: Array, key?: string, con?: string): string; /** 将所有source的成员添加到dist里去.等价于 dist.push(...source) */ export declare function arrAdd(dist: Array, source: Array): any[]; /** 向p前方添加n个s的字符串 */ export declare function prefix0(p: string | number, n?: number, s?: number | string): string; /** 将参数转化成Date类型 */ export declare function snd2Date(p?: string | number | Date): Date; /** 格式化时间日期 代表天的是大写D而非小写d */ export declare function formatDate(p?: string | number | Date, formatter?: string): string; /** 事件日期转化成UTC秒数 */ export declare function date2int(p: string | Date): number; /** 取时间戳中 的日期 */ export declare function t2d(time: number | string | Date): number; /** 返回当前日期 加上 day天数后的时间戳 */ export declare function d2t(day: number): number; /** 计算两个时间相差的天数 */ export declare function daysBetweenTimestamp(time1: string | number | Date, time2: string | number | Date): number; /** 获取随机字符串 */ export declare function randStr(prefix?: string, len?: number): string; /** 字符串转字符流 */ export declare function s2ab(s: any): any[] | ArrayBuffer; /** 任意数据转字符串化,主要是转化为JSON.stringify; */ export declare function tostr(param: any): string; /** 取整数部分;输入不是正数则返回0 */ export declare function touint(param: any): number; /** async下的 延迟 */ export declare function sleep(millisecond: number | string): Promise; /** 类似parseint 但是会将nan变为0返回 */ export declare function toInt(param: any): number; /** 数组转Uint8Array */ export declare function createUint8Array(source: number[], distLen?: number): Uint8Array; /** 具有深度的克隆数据,与cp不同的是,防止js无限引用导致的JSON.stringify报错 */ export declare function clo(p: T, _deep?: number): T; /** 将s的所有成员根据deep限制的前提下赋值给t,不同于Object.assign的地方是具有深度 */ export declare function assign(t: T, s: S, _deep?: number): T & S; /** 执行eval,防止浏览器报错 */ export declare function mevl(funStr: string): any; /** 具有异常避免的执行eval */ export declare function evalDef(str: string, def: T): T; /** 获取o的属性名 */ export declare function objToStr(o: any): string; /** 是否Date类型 */ export declare function isDate(o: any): o is Date; /** 是否数字,字符串数字也返回true */ export declare function isNumber(p: any): p is number; /** 是否整数,字符串数字也返回true */ export declare function isInt(p: any): p is number; /** 是否正整数 */ export declare function isUint(p: any): p is number; /** 是否字符串 */ export declare function isString(p: any): p is string; /** 是否字符串且不为"" */ export declare function isStringT(p: any): p is string; /** 是否数字或者字符串 */ export declare function isNS(p: any): p is number | string; /** 是否数字或者字符串,且 当为数字时不为0,当为字符串时不为"" */ export declare function isNst(p: any): p is number | string; /** 是否为空 */ export declare function isNull(p: any): p is undefined | null; /** 是否Obj类型 */ export declare function isObj(p: any): p is Object; /** 是否数组 */ export declare function isArr(p: any): p is Array; /** 是否数组 */ export declare function isArrT(p: any, min?: number): p is Array; /** 是否正则表达式 */ export declare function isRegExp(o: any): o is RegExp; /** 是否是Map类型 */ export declare function isMap(o: any): o is Map; /** 是否为原生设置 */ export declare function isSet(o: any): o is Set; /** 是否Promise */ export declare function isPromise(o: any): o is Promise; /** 获取RegExp的标志 */ export declare function getRegExpFlags(re: RegExp): string; /** 克隆数据,不同于clo的地方是错误更少,但效率更低 */ export declare function clone(parent: T, circular?: any, depth?: number, prototype?: any, includeNonEnumerable?: any): T; /** 简单的数学计算 */ export declare const math: { getBigInt(p: any): bigint; getBigInts(p: any[]): bigint[]; abs(p: any): string; add(...arg: any[]): string; sub(...arg: any[]): string; mul(...arg: any[]): string; div(...arg: any[]): string; decdiv(dec: number, ...arg: any[]): string; rem(...arg: any[]): string; bitAnd(...arg: any[]): string; bitOr(...arg: any[]): string; bitXor(...arg: any[]): string; bitNot(...arg: any): string; bitShl(...arg: any[]): string; bitShr(...arg: any[]): string; }; /** 克隆Uint8Array */ export declare function cloneUint8Array(p: Uint8Array | number[] | obj): Uint8Array; /** 根据id查找数组 */ export declare function findById(arr: Array, id?: string): T | undefined; /** 根据id查找数组:返回下标 */ export declare function findIndexById(arr: Array, id?: string): number; /** 数字格式化成金额样式,保持小数点两位 * @param {any}p 要转换的数据 * @param {any}minus 是否负数 * @returns {string} 转换后的结果 */ export declare function getDisplayMoney(p?: any, minus?: any): string; /** 将数组的name字段通过|进行拼接 */ export declare function joinNames(...arg: any): string; /** 删除dist原有的所有属性,使用source的所有属性进行填充 */ export declare function copyObj(dist?: any, source?: T, saveDist?: any): any; /** 删除dist原有的所有成员,使用source的所有成员进行填充 */ export declare function copyArr>(dist?: T, source?: T): T | undefined; /** 获取obj的属性值,property的值是以.进行连接的,而不是js中字面量以[]进行连接 */ export declare function getObjProperty(p: any, property?: string, def?: T): T; /** 获取Async类型的数据属性值 */ export declare function getObjPropertyAsync(p: any, property?: string, def?: T, ...params: any): Promise; /** 设置默认值,当dist为undefined|null 或数据类型与source不同时,返回source,否则返回dist */ export declare function setDefaults(dist: any, source: T): T; /** 安全的eval * @param {string} code 需要运行的字符串代码;如果字符串是个function表达式,则会执行这个function * @param {def} def 如果代码执行出错,则返回def * @param {any[]} params 需要给代码添加的执行参数 * @return {T} 返回执行结果 */ export declare function meval(code: string, def?: T, ...params: any[]): T | undefined; /** 根据后缀获取文件类型 */ export declare function mime(path: string): "html" | "text" | "img" | "audio" | "video" | "tjs" | "file"; export declare function out(data: any, refsh?: any): void; export declare function formatUrl(url?: string, baseUrl?: string): string; export declare function existUni(): boolean;