@ghini/kit
Version:
js practical tools to assist efficient development
82 lines (81 loc) • 3.6 kB
TypeScript
export const exefile: string;
export const exedir: string;
export const exeroot: any;
export const metaroot: any;
export function xpath(targetPath: any, basePath?: string, separator?: string): string;
export function fileurl2path(url: string): string;
export function stamps(date: any): number;
export function date(timestamp: any, offset?: number): string;
export function now(): number;
export function sleep(ms: number): Promise<void>;
export function interval(fn: Function, ms: number, PX?: number): Promise<void>;
export function timelog(fn: any): Promise<void>;
export const ttl: TTLMap;
export class TTLMap {
constructor(options?: {
defaultTTL?: number;
cleanupInterval?: number;
});
storage: Map<any, any>;
expiryMap: Map<any, any>;
expiryHeap: any[];
heapIndices: Map<any, any>;
lastCleanup: number;
cleanupInterval: number;
defaultTTL: number;
set(key: any, value: any, ttl?: number): TTLMap;
updateTTL(key: any, ttl: number): boolean;
getTTL(key: any): number | undefined;
get(key: any): any;
has(key: any): boolean;
keys(): any[];
values(): any[];
entries(): any[];
delete(key: any): boolean;
clear(): void;
get size(): number;
private _siftUp;
private _siftDown;
private _removeFromHeap;
private _lazyCleanup;
cleanup(): number;
[Symbol.iterator](): MapIterator<[any, any]>;
}
export function rf(filename: string, option?: string): string | null;
export function wf(filename: string, data: string | Buffer, append?: boolean, option?: string): boolean;
export function mkdir(dir: any): undefined;
export function isdir(path: string): boolean | undefined;
export function isfile(path: string): boolean | undefined;
export function dir(path: string): string[] | undefined;
export function exist(path: string): boolean;
export function rm(targetPath: string): undefined;
export function cp(oldPath: string, newPath: string): void;
export function env(filePath: string, cover?: boolean): Promise<object>;
export function exe(command: any, log?: boolean): Promise<any>;
export function arf(filename: any, option?: string): Promise<Buffer<ArrayBufferLike> & string>;
export function awf(filename: any, data: any, append?: boolean, option?: string): Promise<boolean>;
export function amkdir(dir: any): Promise<string>;
export function aisdir(path: any): Promise<boolean>;
export function aisfile(path: any): Promise<boolean>;
export function adir(path: any): Promise<string[]>;
export function aexist(path: any): Promise<boolean>;
export function arm(targetPath: any, confirm?: boolean): Promise<boolean>;
export function aonedir(dir: any): Promise<string>;
export function astat(path: any): Promise<fs.Stats>;
export function aloadyml(filePath: string): Promise<any>;
export function aloadjson(filePath: any): Promise<any>;
export function cookie_obj(str: any): {
value: {};
flags: {};
};
export function cookie_str(obj: any): string;
export function cookie_merge(str1: any, str2: any): string;
export function cookies_obj(str: any): any;
export function cookies_str(obj: any): string;
export function cookies_merge(str1: any, str2: any): string;
export function mreplace(str: string, replacements: Array<[string | RegExp, string]>): string;
export function mreplace_calc(str: string, replacements: Array<[string | RegExp, string]>): [string, Array<[number, string | RegExp]>, Array<[number, string]>];
export function xreq(path: string): object;
export function ast_jsbuild(code: string): string;
export function gcatch(open?: boolean): void;
import fs from "fs";