123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592 |
- export = utility;
- export as namespace utility;
- declare namespace utility {
-
-
- type ObjStatic = { [key: string]: any };
-
- function randomSlice(
- arr: any[],
- num?: number,
- ): any[];
-
- function spliceOne(
- arr: any[],
- index: number,
- ): any[];
-
-
- function hash(
- method: 'md5' | 'sha1',
- s: string | Buffer | Object,
- format?: 'hex' | 'base64',
- ): string;
-
- function md5(
- s: string | Buffer | Object,
- format?: 'hex' | 'base64',
- ): string;
-
- function sha1(
- s: string | Buffer | Object,
- format?: 'hex' | 'base64',
- ): string;
-
- function sha256(
- s: string | Buffer | Object,
- format?: 'hex' | 'base64',
- ): string;
-
- function hmac(
- algorithm: string,
- key: string,
- data: string | Buffer,
- encoding?: 'base64' | string,
- ): string;
-
- function base64encode(
- s: string | Buffer,
- urlsafe?: boolean,
- ): string;
-
- function base64decode(
- encode: string,
- urlsafe?: boolean,
- encoding?: 'utf8' | 'buffer',
- ): string | Buffer;
-
- interface IYYYYMMDDHHmmssStaticOptions {
- dateSep?: string,
- timeSep?: string,
- }
- interface IDateStructStaticReturns {
- YYYYMMDD: number,
- H: number,
- }
-
- function accessLogDate(d: Date): string;
-
- function logDate(
- d: string | Date,
- msSep?: string,
- ): string;
-
- function YYYYMMDDHHmmss(
- d: Date | string,
- options?: IYYYYMMDDHHmmssStaticOptions,
- ): string;
-
- function YYYYMMDD(
- d: string | Date,
- sep?: string,
- ): string;
-
- function datestruct(
- now?: Date,
- ): IDateStructStaticReturns;
-
- function timestamp(
- t?: string | number,
- ): number | Date;
-
-
- function noop(): () => any;
-
- function getParamNames(
- func: (...args: any[]) => any,
- cache?: boolean,
- ): string[];
-
- interface IJSONStaticOptions {
- space?: number | string,
- replacer?: (
- key: string,
- value: any,
- ) => any,
- }
- function strictJSONParse(
- str: string,
- ): ObjStatic;
- function readJSONSync(
- filepath: string,
- ): ObjStatic;
- function writeJSONSync(
- filepath: string,
- str: string | ObjStatic,
- options?: IJSONStaticOptions,
- ): void;
- function readJSON(
- filepath: string,
- ): Promise<any>;
- function writeJSON(
- filepath: string,
- str: string | ObjStatic,
- options?: IJSONStaticOptions,
- ): Promise<any>;
- function mkdir(
- dir: string,
- ): Promise<any>;
-
-
- const MAX_SAFE_INTEGER: number;
- const MIN_SAFE_INTEGER: number;
- const MAX_SAFE_INTEGER_STR: string;
- const MAX_SAFE_INTEGER_STR_LENGTH: number;
-
- function isSafeNumberString(
- s: string,
- ): boolean;
-
- function toSafeNumber(
- s: string | number,
- ): number | string;
-
- function random(
- lower?: number,
- upper?: number,
- ): number;
-
-
- function assign(
- target: ObjStatic,
- objects: ObjStatic | any[],
- ): ObjStatic;
- function has(
- obj: ObjStatic,
- prop: string,
- ): boolean;
- function getOwnEnumerables(
- obj: ObjStatic,
- ignoreNull?: boolean,
- ): string[];
-
- function map(
- obj?: ObjStatic,
- ): ObjStatic;
-
- interface ITryStaticReturns {
- error: Error | undefined,
- value: any,
- }
- const UNSTABLE_METHOD: {
-
- try: (
- fn: (...args: any[]) => any,
- ) => ITryStaticReturns,
- };
-
- function dig(
- obj: ObjStatic,
- ...args: any[],
- ): any;
-
- function argumentsToArray(
- ...args: any[],
- ): any[];
-
- function setImmediate(
- callback: (...args: any[]) => void,
- ...args: any[],
- ): NodeJS.Immediate;
- function setImmediate(
- fn: (...args: any[]) => any,
- ...args: any[],
- ): void;
-
- interface IReplaceInvalidHttpHeaderCharReturns {
- val: string,
- invalid: boolean,
- }
- function randomString(
- length?: number,
- charSet?: string | string[],
- ): string;
-
- function split(
- str: string,
- sep?: string,
- ): string[];
-
- function splitAlwaysOptimized(
- ...args: any[],
- ): string[];
-
- function replace(
- str: string,
- substr: string | RegExp,
- newSubstr: string | ((...args: any[]) => any),
- ): string;
-
- function replaceInvalidHttpHeaderChar(
- val: string,
- replacement?: string | ((...args: any[]) => any)
- ): IReplaceInvalidHttpHeaderCharReturns;
-
- function includesInvalidHttpHeaderChar(
- val: string,
- ): boolean;
-
-
- function escape(
- test: string,
- ): string;
-
- function unescape(
- html: string,
- type?: string,
- ): string | ObjStatic;
-
- function encodeURIComponent(
- text: string,
- ): string;
-
- function decodeURIComponent(
- encodeText: string,
- ): string;
- }
|