diff --git a/types/adone/adone.d.ts b/types/adone/adone.d.ts
index a4f102752c..34540761b5 100644
--- a/types/adone/adone.d.ts
+++ b/types/adone/adone.d.ts
@@ -1,85 +1,133 @@
///
-declare const _null: symbol;
-export { _null as null };
-export function noop(): void;
-export function identity(x: T): T;
-export function truly(): true;
-export function falsely(): false;
-export const ok: "OK";
-export const bad: "BAD";
-export const exts: [".js", ".tjs", ".ajs"];
-export function log(...args: any[]): void;
-export function fatal(...args: any[]): void;
-export function error(...args: any[]): void;
-export function warn(...args: any[]): void;
-export function info(...args: any[]): void;
-export function debug(...args: any[]): void;
-export function trace(...args: any[]): void;
-export function o(...props: any[]): object;
-export const Date: typeof global.Date;
-export const hrtime: typeof global.process.hrtime;
-export const setTimeout: typeof global.setTimeout;
-export const setInterval: typeof global.setInterval;
-export const setImmediate: typeof global.setImmediate;
-export const clearTimeout: typeof global.clearTimeout;
-export const clearInterval: typeof global.clearInterval;
-export const clearImmediate: typeof global.clearImmediate;
-interface LazifyOptions {
- configurable: boolean;
+declare namespace adone {
+ const _null: symbol;
+ export { _null as null };
+ export function noop(): void;
+ export function identity(x: T): T;
+ export function truly(): true;
+ export function falsely(): false;
+ export const ok: "OK";
+ export const bad: "BAD";
+ export const exts: [".js", ".tjs", ".ajs"];
+ export function log(...args: any[]): void;
+ export function fatal(...args: any[]): void;
+ export function error(...args: any[]): void;
+ export function warn(...args: any[]): void;
+ export function info(...args: any[]): void;
+ export function debug(...args: any[]): void;
+ export function trace(...args: any[]): void;
+ export function o(...props: any[]): object;
+ export const Date: typeof global.Date;
+ export const hrtime: typeof global.process.hrtime;
+ export const setTimeout: typeof global.setTimeout;
+ export const setInterval: typeof global.setInterval;
+ export const setImmediate: typeof global.setImmediate;
+ export const clearTimeout: typeof global.clearTimeout;
+ export const clearInterval: typeof global.clearInterval;
+ export const clearImmediate: typeof global.clearImmediate;
+
+ namespace I {
+ interface LazifyOptions {
+ /**
+ * Whether the new properties are configurable, false by default
+ */
+ configurable?: boolean;
+
+ /**
+ * Whether the new properties are writable, false by default
+ */
+ writable?: boolean;
+
+ /**
+ * A custom mapper for values, by default returns the exported object (module.exports),
+ * but if the object is a transpiled es module and the default export is defined,
+ * it returns the default export
+ *
+ * @param key property
+ * @param mod module.exports
+ */
+ mapper?(key: string, mod: any): any;
+ }
+ }
+
+ /**
+ * Extends the given object(or creates a new one) with the given lazyfied properties
+ */
+ export function lazify(modules: object, obj?: object, require?: (path: string) => any, options?: I.LazifyOptions): object;
+
+ /**
+ * Defines or extends the private part of the given object with the given lazyfied properties
+ */
+ export function lazifyPrivate(modules: object, obj?: object, require?: (path: string) => any, options?: I.LazifyOptions): object;
+
+ /**
+ * Defines the private part of the given object with the given modules
+ */
+ export function definePrivate(modules: object, obj: object): object;
+
+ /**
+ * Returns the private part of the given object
+ */
+ export function private(obj: object): any;
+
+ namespace I {
+ interface Tag {
+ set(Class: object, tag: string): void;
+ has(obj: object, tag: string): boolean;
+ define(tag: string, predicate?: string): void;
+ SUBSYSTEM: symbol;
+ APPLICATION: symbol;
+ TRANSFORM: symbol;
+ CORE_STREAM: symbol;
+ LOGGER: symbol;
+ LONG: symbol;
+ BIGNUMBER: symbol;
+ EXBUFFER: symbol;
+ EXDATE: symbol;
+ CONFIGURATION: symbol;
+ GENESIS_NETRON: symbol;
+ GENESIS_PEER: symbol;
+ NETRON: symbol;
+ NETRON_PEER: symbol;
+ NETRON_ADAPTER: symbol;
+ NETRON_DEFINITION: symbol;
+ NETRON_DEFINITIONS: symbol;
+ NETRON_REFERENCE: symbol;
+ NETRON_INTERFACE: symbol;
+ NETRON_STUB: symbol;
+ NETRON_REMOTESTUB: symbol;
+ NETRON_STREAM: symbol;
+ FAST_STREAM: symbol;
+ FAST_FS_STREAM: symbol;
+ FAST_FS_MAP_STREAM: symbol;
+ }
+ }
+ export const tag: I.Tag;
+ export function bind(libName: string): object;
+ export function getAssetAbsolutePath(relPath: string): string;
+ export function loadAsset(relPath: string): string | Buffer;
+ export function require(path: string): object;
+ export const package: object;
+
+ namespace I {
+ interface Runtime {
+ term: object; // TODO
+ logger: object; // TODO
+ app: object; // TODO
+ }
+ }
+
+ export const runtime: I.Runtime;
+
+ export const homePath: string;
+ export const rootPath: string;
+ export const etcPath: string;
+ export const config: object;
+ export const emptyBuffer: Buffer;
+
+ export const assert: assertion.I.AssertFunction;
+ export const expect: assertion.I.ExpectFunction;
+
+ export const std: typeof nodestd;
}
-export function lazify(modules: object, obj?: object, require?: (path: string) => any, options?: LazifyOptions): object;
-interface Tag {
- set(Class: object, tag: string): void;
- has(obj: object, tag: string): boolean;
- define(tag: string, predicate?: string): void;
- SUBSYSTEM: symbol;
- APPLICATION: symbol;
- TRANSFORM: symbol;
- CORE_STREAM: symbol;
- LOGGER: symbol;
- LONG: symbol;
- BIGNUMBER: symbol;
- EXBUFFER: symbol;
- EXDATE: symbol;
- CONFIGURATION: symbol;
- GENESIS_NETRON: symbol;
- GENESIS_PEER: symbol;
- NETRON: symbol;
- NETRON_PEER: symbol;
- NETRON_ADAPTER: symbol;
- NETRON_DEFINITION: symbol;
- NETRON_DEFINITIONS: symbol;
- NETRON_REFERENCE: symbol;
- NETRON_INTERFACE: symbol;
- NETRON_STUB: symbol;
- NETRON_REMOTESTUB: symbol;
- NETRON_STREAM: symbol;
- FAST_STREAM: symbol;
- FAST_FS_STREAM: symbol;
- FAST_FS_MAP_STREAM: symbol;
-}
-export const tag: Tag;
-export function run(App: object, ignoreArgs?: boolean): Promise;
-export function bind(libName: string): object;
-export function getAssetAbsolutePath(relPath: string): string;
-export function loadAsset(relPath: string): string | Buffer;
-export function require(path: string): object;
-export const package: object;
-
-import * as std from "./glosses/std";
-export { std };
-
-export * from "./glosses/common";
-export * from "./glosses/math";
-export * from "./glosses/utils";
-export * from "./glosses/assertion";
-export * from "./glosses/promise";
-export * from "./glosses/shani";
-
-import "./glosses/shani-global";
-
-export const assert: adone.assertion.I.AssertFunction;
-export const expect: adone.assertion.I.ExpectFunction;
-
-export as namespace adone;
diff --git a/types/adone/glosses/application.d.ts b/types/adone/glosses/application.d.ts
new file mode 100644
index 0000000000..6b2b783d68
--- /dev/null
+++ b/types/adone/glosses/application.d.ts
@@ -0,0 +1,5 @@
+declare namespace adone {
+ namespace application {
+ function run(app: object, ignoreArgs?: boolean): Promise;
+ }
+}
diff --git a/types/adone/glosses/archives.d.ts b/types/adone/glosses/archives.d.ts
new file mode 100644
index 0000000000..3f059ff14d
--- /dev/null
+++ b/types/adone/glosses/archives.d.ts
@@ -0,0 +1,670 @@
+declare namespace adone {
+ /**
+ * Various archivers
+ */
+ namespace archive {
+ /**
+ * tar archiver
+ */
+ namespace tar {
+ namespace I {
+ interface Header {
+ /**
+ * File path
+ */
+ name: string;
+
+ /**
+ * Type of entry, file by default
+ */
+ type: "file" | "directory" | "link" | "symlink" | "block-device" | "character-device" | "fifo" | "contiguous-file";
+
+ /**
+ * Entry mode, 0755 for dirs and 0644 by default
+ */
+ mode: number;
+
+ /**
+ * Last modified date for entry, now by default
+ */
+ mtime: number;
+
+ /**
+ * Entry size, 0 by default
+ */
+ size: number;
+
+ /**
+ * Linked file name
+ */
+ linkname: string;
+
+ /**
+ * uid for entry owner, 0 by default
+ */
+ uid: number;
+
+ /**
+ * gid for entry owner, 9 by default
+ */
+ gid: number;
+
+ /**
+ * uname of entry owner, null by default
+ */
+ uname: string;
+
+ /**
+ * gname of entry owner, null by default
+ */
+ gname: string;
+
+ /**
+ * device minor versio, 0 by default
+ */
+ devmajor: number;
+
+ /**
+ * device minor version, 0 by default
+ */
+ devminor: number;
+ }
+
+ type Optional = {
+ [P in keyof T]?: T[P];
+ };
+
+ interface OptionalHeader extends Optional {
+ /**
+ * File path
+ */
+ name: string;
+ }
+
+ interface CommonOptions {
+ /**
+ * Entries filter
+ */
+ ignore?(name: string): boolean;
+
+ /**
+ * Header mapper, called for each each entry
+ */
+ map?(header: Header): Header | undefined;
+
+ /**
+ * Set the dmode and fmode to writable
+ */
+ readable?: boolean;
+
+ /**
+ * Set the dmode and fmode to writable
+ */
+ writable?: boolean;
+
+ /**
+ * Strip the parts of paths of files
+ */
+ strip?: number;
+
+ /**
+ * Ensure that packed directories have the corresponding modes
+ */
+ dmode?: number;
+
+ /**
+ * Ensure that packed files have the corresponding modes
+ */
+ fmode?: number;
+
+ /**
+ * A custom umask, process.umask() by default
+ */
+ umask?: number;
+ }
+
+ interface PackOptions extends CommonOptions {
+ /**
+ * Input read stream modifier, called for each entry
+ */
+ mapStream?(stream: fs.I.ReadStream, header: Header): nodestd.stream.Readable;
+
+ /**
+ * Pack the contents of the symlink instead of the link itself, false by default
+ */
+ dereference?: boolean;
+
+ /**
+ * Specifies which entries to pack, all by default
+ */
+ entries?: string[];
+
+ /**
+ * Whether to sort entries before packing
+ */
+ sort?: boolean;
+
+ /**
+ * set false to ignore errors due to unsupported entry types (like device files), true by default
+ */
+ strict?: boolean;
+
+ /**
+ * A custom initial pack stream
+ */
+ pack?: RawPackStream;
+ }
+
+ type Writable = nodestd.stream.Writable;
+
+ interface LinkSink extends Writable {
+ linkname: string;
+ }
+
+ interface UnpackOptions extends CommonOptions {
+ /**
+ * Input read stream modifier, called for each entry
+ */
+ mapStream?(stream: UnpackSourceStream, header: Header): nodestd.stream.Readable;
+
+ /**
+ * Whether to change time properties of files
+ */
+ utimes?: boolean;
+
+ /**
+ * Whether to change owner of the files
+ */
+ chown?: boolean;
+
+ /**
+ * A custom unpack stream
+ */
+ unpack?: RawUnpackStream;
+
+ /**
+ * Copies a file if cannot create a link
+ */
+ hardlinkAsFilesFallback?: boolean;
+ }
+
+ interface UnpackSourceStream extends nodestd.stream.PassThrough {
+ _parent: RawUnpackStream;
+ }
+ }
+
+ /**
+ * Represents a raw tar unpack stream
+ */
+ class RawPackStream extends nodestd.stream.Readable {
+ entry(header: I.OptionalHeader, buffer: Buffer, callback?: (err: any) => void): I.Writable;
+ entry(header: I.OptionalHeader & { type: "symblink", linkname: string }, callback?: (err: any) => void): I.Writable;
+ entry(header: I.OptionalHeader & { type: "symlink" }, callback?: (err: any) => void): I.LinkSink;
+ entry(header: I.OptionalHeader, callback?: (err: any) => void): I.Writable;
+
+ finalize(): void;
+
+ destroy(err?: any): void;
+ }
+
+ /**
+ * Represents a raw writable unpack stream
+ */
+ class RawUnpackStream extends nodestd.stream.Writable {
+ on(event: string, listener: (...args: any[]) => void): this;
+ on(event: "entry", listener: (header: I.Header, stream: I.UnpackSourceStream, next: (err?: any) => void) => void): this;
+ on(event: "close", listener: () => void): this;
+ on(event: "drain", listener: () => void): this;
+ on(event: "error", listener: (err: Error) => void): this;
+ on(event: "finish", listener: () => void): this;
+ on(event: "pipe", listener: (src: nodestd.stream.Readable) => void): this;
+ on(event: "unpipe", listener: (src: nodestd.stream.Readable) => void): this;
+
+ once(event: string, listener: (...args: any[]) => void): this;
+ once(event: "entry", listener: (header: I.Header, stream: I.UnpackSourceStream, next: (err?: any) => void) => void): this;
+ once(event: "close", listener: () => void): this;
+ once(event: "drain", listener: () => void): this;
+ once(event: "error", listener: (err: Error) => void): this;
+ once(event: "finish", listener: () => void): this;
+ once(event: "pipe", listener: (src: nodestd.stream.Readable) => void): this;
+ once(event: "unpipe", listener: (src: nodestd.stream.Readable) => void): this;
+ }
+
+ /**
+ * Creates a pack stream for the files from the given directory
+ *
+ * @param cwd directory to pack
+ */
+ function packStream(cwd: string, options?: I.PackOptions): RawPackStream;
+
+ /**
+ * Creates an unpack stream to the given direcotry
+ *
+ * @param cwd direcotry to unpack to
+ */
+ function unpackStream(cwd: string, options?: I.UnpackOptions): RawUnpackStream;
+ }
+
+ /**
+ * zip archiver
+ */
+ namespace zip {
+ /**
+ * zip packer
+ */
+ namespace pack {
+ class ZipFile {
+ /**
+ * A readable stream that will produce the contents of the zip file
+ */
+ outputStream: nodestd.stream.Readable;
+
+ /**
+ * Adds a file from the file system at realPath into the zipfile as metadataPath
+ *
+ * @param path path to the file
+ * @param metadataPath path to the file inside the archive
+ */
+ addFile(path: string, metadataPath: string, options?: {
+ /**
+ * Overrides the value that will be obtained from stat
+ */
+ mtime?: number,
+
+ /**
+ * Overrides the value that will be obtained from stat
+ */
+ mode?: number,
+
+ /**
+ * If true, the file data will be deflated (compression method 8).
+ *
+ * If false, the file data will be stored (compression method 0)
+ */
+ compress?: boolean,
+
+ /**
+ * Use ZIP64 format in this entry's Data Descriptor and Central Directory Record
+ * regardless of if it's required or not (this may be useful for testing.).
+ * Otherwise, packer will use ZIP64 format where necessary.
+ */
+ forceZip64Format?: boolean
+ }): this;
+
+ /**
+ * Adds a file to the zip file whose content is read from readStream
+ *
+ * @param stream a readable stream for the file
+ * @param metadataPath path to the file inside the archive
+ */
+ addReadStream(stream: nodestd.stream.Readable, metadataPath: string, options?: {
+ /**
+ * Defines modified date, now by default
+ */
+ mtime?: number,
+
+ /**
+ * Defines file mode, 0o100664 by default
+ */
+ mode?: number,
+
+ /**
+ * If true, the file data will be deflated (compression method 8).
+ *
+ * If false, the file data will be stored (compression method 0)
+ */
+ compress?: boolean,
+
+ /**
+ * Use ZIP64 format in this entry's Data Descriptor and Central Directory Record
+ * regardless of if it's required or not (this may be useful for testing.).
+ * Otherwise, packer will use ZIP64 format where necessary.
+ */
+ forceZip64Format?: boolean,
+
+ /**
+ * If given, it will be checked against the actual number of bytes in the readStream,
+ * and an error will be emitted if there is a mismatch
+ */
+ size?: number
+ }): this;
+
+ /**
+ * Adds a file to the zip file whose content is buffer
+ *
+ * @param buffer the file's contents, must be at most 0x3fffffff bytes long
+ * @param metadataPath path to the file inside the archive
+ */
+ addBuffer(buffer: Buffer, metadataPath: string, options?: {
+ /**
+ * Defines modified date, now by default
+ */
+ mtime?: number,
+
+ /**
+ * Defines file mode, 0o100664 by default
+ */
+ mode?: number,
+
+ /**
+ * If true, the file data will be deflated (compression method 8).
+ *
+ * If false, the file data will be stored (compression method 0)
+ */
+ compress?: boolean,
+
+ /**
+ * Use ZIP64 format in this entry's Data Descriptor and Central Directory Record
+ * regardless of if it's required or not (this may be useful for testing.).
+ * Otherwise, packer will use ZIP64 format where necessary.
+ */
+ forceZip64Format?: boolean
+ }): this;
+
+ /**
+ * Adds an entry to the zip file that indicates a directory should be created,
+ * even if no other items in the zip file are contained in the directory
+ */
+ addEmptyDirectory(metadataPath: string, options?: {
+ /**
+ * Defines modified date, now by default
+ */
+ mtime?: number,
+
+ /**
+ * Defines file mode, 0o40775 by default
+ */
+ mode?: number
+ }): this;
+
+ /**
+ * Indicates that no more files will be added via addFile(), addReadStream(), or addBuffer().
+ * Some time after calling this function, outputStream will be ended.
+ *
+ * @returns the final guessed size of the file, can be -1 if it is hard to guess before processing. This will happend
+ * only if compression is enabled, or a stream with no size hint given
+ */
+ end(options?: {
+ /**
+ * If true, packet will include the ZIP64 End of Central Directory Locator and ZIP64 End of Central Directory Record
+ * regardless of whether or not they are required (this may be useful for testing.).
+ * Otherwise, packer will include these structures if necessary
+ */
+ forceZip64Format?: boolean
+ }): Promise;
+ }
+ }
+
+ /**
+ * zip unpacker
+ */
+ namespace unpack {
+ namespace I {
+ interface ExtraField {
+ id: number;
+ data: Buffer;
+ }
+
+ interface Entry {
+ versionMadeBy: number;
+ versionNeededToExtract: number;
+ generalPurposeBitFlag: number;
+ compressionMethod: number;
+ lastModFileTime: number;
+ lastModFileDate: number;
+ crc32: number;
+ compressedSize: number;
+ uncompressedSize: number;
+ fileNameLength: number;
+ extraFieldLength: number;
+ fileCommentLength: number;
+ internalFileAttributes: number;
+ externalFileAttributes: number;
+ relativeOffsetOfLocalHeader: number;
+
+ /**
+ * The bytes for the file name are decoded with UTF-8 if generalPurposeBitFlag & 0x800, otherwise with CP437.
+ * Alternatively, this field may be populated from the Info-ZIP Unicode Path Extra Field (see extraFields).
+ */
+ fileName: StringType;
+
+ extraFields: ExtraField[];
+
+ /**
+ * Comment decoded with the charset indicated by generalPurposeBitFlag & 0x800 as with the fileName
+ */
+ fileComment: StringType;
+
+ getLastModDate(): adone.I.datetime.Datetime;
+
+ /**
+ * Whether this entry is encrypted with "Traditional Encryption"
+ */
+ isEncrypted(): boolean;
+
+ /**
+ * Whether the entry is compressed
+ */
+ isCompressed(): boolean;
+ }
+
+ interface ZipFile extends event.EventEmitter {
+ /**
+ * true until close() is called; then it's false
+ */
+ isOpen: boolean;
+
+ /**
+ * Total number of central directory records
+ */
+ entryCount: number;
+
+ /**
+ * Always decoded with CP437 per the spec
+ */
+ comment: StringType;
+
+ /**
+ * Causes all future calls to openReadStream() to fail,
+ * and closes the fd after all streams created by openReadStream() have emitted their end events
+ */
+ close(): void;
+
+ readEntry(): Promise;
+
+ /**
+ * Opens a read stream for the given entry
+ */
+ openReadStream(entry: Entry, options?: {
+ /**
+ * The option must be omitted when the entry is not compressed (see isCompressed()),
+ * and either true (or omitted) or false when the entry is compressed.
+ * Specifying decompress: false for a compressed entry causes the read stream
+ * to provide the raw compressed file data without going through a zlib inflate transform
+ */
+ decompress?: boolean,
+
+ /**
+ * The option must be null (or omitted) for non-encrypted entries,
+ * and false for encrypted entries. Omitting the option for an encrypted entry will result in an err.
+ */
+ decrypt?: boolean,
+
+ /**
+ * The start byte offset (inclusive) into this entry's file data
+ */
+ start?: number,
+
+ /**
+ * The end byte offset (exclusive) into this entry's file data
+ */
+ end?: number,
+ }): Promise;
+
+ /**
+ * Emitted for each entry.
+ *
+ * If decodeStrings is true, entries emitted via this event have already passed file name validation
+ *
+ * If validateEntrySizes is true and this entry's compressionMethod is 0 (stored without compression),
+ * this entry has already passed entry size validation
+ */
+ on(event: "entry", listener: (entry: Entry) => void): this;
+
+ /**
+ * Emitted after the last entry event has been emitted
+ */
+ on(event: "end", listener: () => void): this;
+
+ /**
+ * Emitted after the fd is actually closed
+ */
+ on(event: "close", listener: () => void): this;
+
+ /**
+ * Emitted in the case of errors with reading the zip file
+ */
+ on(event: "error", listener: (err: any) => void): this;
+
+ /**
+ * Emitted for each entry.
+ *
+ * If decodeStrings is true, entries emitted via this event have already passed file name validation
+ *
+ * If validateEntrySizes is true and this entry's compressionMethod is 0 (stored without compression),
+ * this entry has already passed entry size validation
+ */
+ once(event: "entry", listener: (entry: Entry) => void): this;
+
+ /**
+ * Emitted after the last entry event has been emitted
+ */
+ once(event: "end", listener: () => void): this;
+
+ /**
+ * Emitted after the fd is actually closed
+ */
+ once(event: "close", listener: () => void): this;
+
+ /**
+ * Emitted in the case of errors with reading the zip file
+ */
+ once(event: "error", listener: (err: any) => void): this;
+ }
+
+ interface CommonOptions {
+ /**
+ * Indicates that entries should be read only when readEntry() is called.
+ * If lazyEntries is false, entry events will be emitted as fast as possible
+ * to allow pipe()-ing file data from all entries in parallel.
+ *
+ * Default is false
+ */
+ lazyEntries?: boolean;
+
+ /**
+ * Causes unpacker to decode strings with CP437 or UTF-8 as required by the spec.
+ *
+ * When turned off zipfile.comment, entry.fileName, and entry.fileComment will be Buffer,
+ * any Info-ZIP Unicode Path Extra Field will be ignored, automatic file name validation will not be performed
+ */
+ decodeStrings?: boolean;
+
+ /**
+ * Ensures that an entry's reported uncompressed size matches its actual uncompressed size
+ */
+ validateEntrySizes?: boolean;
+ }
+
+ interface PathOptions extends CommonOptions {
+ /**
+ * Autocloses the file after the last entry reading or when an error occurs
+ *
+ * Default is true
+ */
+ autoClose?: boolean;
+ }
+
+ interface FdOptions extends CommonOptions {
+ /**
+ * Autocloses the file after the last entry reading or when an error occurs
+ *
+ * Default is false
+ */
+ autoClose?: boolean;
+ }
+
+ type BufferOptions = CommonOptions;
+
+ interface RandomAccessReaderOptions extends CommonOptions {
+ /**
+ * Autocloses the file after the last entry reading or when an error occurs
+ *
+ * Default is true
+ */
+ autoClose?: boolean;
+ }
+ }
+
+ /**
+ * Opens a file and creates a zipfile unpacker
+ */
+ function open(path: string, options: I.PathOptions & { decodeStrings: false }): I.ZipFile;
+
+ /**
+ * Opens a file and creates a zipfile unpacker
+ */
+ function open(path: string, options?: I.PathOptions): I.ZipFile;
+
+ /**
+ * Creates a zipfile unpacker for the given fd
+ */
+ function fromFd(fd: number, options: I.FdOptions & { decodeStrings: false }): I.ZipFile;
+
+ /**
+ * Creates a zipfile unpacker for the given fd
+ */
+ function fromFd(fd: number, options?: I.FdOptions): I.ZipFile;
+
+ /**
+ * Creates a zipfile unpacker for the given buffer
+ */
+ function fromBuffer(buffer: Buffer, options: I.BufferOptions & { decodeStrings: false }): I.ZipFile;
+
+ /**
+ * Creates a zipfile unpacker for the given buffer
+ */
+ function fromBuffer(buffer: Buffer, options?: I.BufferOptions): I.ZipFile;
+
+ /**
+ * Creates a zipfile unpacker for the given random access reader.
+ * This method of reading a zip file allows clients to implement their own back-end file system
+ *
+ * @param totalSize Indicates the total file size of the zip file
+ */
+ function fromRandomAccessReader(
+ reader: fs.AbstractRandomAccessReader,
+ totalSize: number,
+ options: I.RandomAccessReaderOptions & { decodeStrings: false }
+ ): I.ZipFile;
+
+ /**
+ * Creates a zipfile unpacker for the given random access reader.
+ * This method of reading a zip file allows clients to implement their own back-end file system
+ *
+ * @param totalSize Indicates the total file size of the zip file
+ */
+ function fromRandomAccessReader(
+ reader: fs.AbstractRandomAccessReader,
+ totalSize: number,
+ options?: I.RandomAccessReaderOptions
+ ): I.ZipFile;
+
+ /**
+ * Returns null or a String error message depending on the validity of fileName
+ */
+ function validateFileName(filename: string): string | null;
+ }
+ }
+ }
+}
diff --git a/types/adone/glosses/assertion.d.ts b/types/adone/glosses/assertion.d.ts
index 4e8bfc593a..e7ba662791 100644
--- a/types/adone/glosses/assertion.d.ts
+++ b/types/adone/glosses/assertion.d.ts
@@ -1,1074 +1,1074 @@
-import adone from "adone";
+declare namespace adone {
+ /**
+ * assertion functions
+ */
+ namespace assertion {
+ namespace I {
+ interface assertion {
+ AssertionError: AssertionError;
+ config: Config;
+ use: UseFunction;
+ loadMockInterface: LoadInterfaceFunction;
+ loadExpectInterface: LoadInterfaceFunction;
+ loadAssertInterface: LoadInterfaceFunction;
+ assert: AssertFunction;
+ expect: ExpectFunction;
+ }
-/**
- * assertion functions
- */
-export namespace assertion {
- namespace I {
- interface assertion {
- AssertionError: AssertionError;
- config: Config;
- use: UseFunction;
- loadMockInterface: LoadInterfaceFunction;
- loadExpectInterface: LoadInterfaceFunction;
- loadAssertInterface: LoadInterfaceFunction;
- assert: AssertFunction;
- expect: ExpectFunction;
+ interface Config {
+ /**
+ * Include stack in Assertion error message
+ */
+ includeStack: boolean;
+ /**
+ * Include `showDiff` flag in the thrown errors
+ */
+ showDiff: boolean;
+ /**
+ * Length threshold for actual and expected values in assertion errors
+ */
+ truncateThreshold: number;
+ /**
+ * use Proxy to throw an error when a non-existent property is read
+ */
+ useProxy: boolean;
+ /**
+ * properties that should be ignored instead of throwing an error if they do not exist on the assertion
+ */
+ proxyExcludedKeys: string[];
+ }
+
+ type PossibleTypes = util.I.PossibleTypes | "array";
+
+ type UseFunction = (fn: () => void) => assertion;
+
+ type LoadInterfaceFunction = () => assertion;
+
+ interface AssertFunction {
+ /**
+ * Asserts that value is truthy
+ */
+ (value: any, message?: string): void;
+ /**
+ * Throws an AssertionError, like node.js
+ */
+ fail(actual?: any, expected?: any, message?: string, operator?: any): void;
+ /**
+ * Asserts that value is truthy
+ */
+ isOk(value: any, message?: string): void;
+ /**
+ * Asserts that value is truthy
+ */
+ ok(value: any, message?: string): void;
+ /**
+ * Asserts that value is falsy
+ */
+ isNotOk(value: any, message?: string): void;
+ /**
+ * Asserts that value is falsy
+ */
+ notOk(value: any, message?: string): void;
+ /**
+ * Asserts non-strict equality
+ */
+ equal(actual: any, expected: any, message?: string): void;
+ /**
+ * Asserts non-strict inequality
+ */
+ notEqual(actual: any, expected: any, message?: string): void;
+ /**
+ * Asserts strict equality
+ */
+ strictEqual(actual: any, expected: any, message?: string): void;
+ /**
+ * Asserts strict inequality
+ */
+ notStrictEqual(actual: any, expected: any, message?: string): void;
+ /**
+ * Asserts that actual is deeply equal to expected
+ */
+ deepEqual(actual: any, expected: any, message?: string): void;
+ /**
+ * Asserts that actual is deeply equal to expected
+ */
+ deepStrictEqual(actual: any, expected: any, message?: string): void;
+ /**
+ * Asserts that actual and expected have the same length and the same members (===)
+ */
+ equalArrays(actual: any[], expected: any[], message?: string): void;
+ /**
+ * Asserts that actual is not deeply equal to expected
+ */
+ notDeepEqual(actual: any, expected: any, message?: string): void;
+ /**
+ * Asserts that value > above
+ */
+ isAbove(value: any, above: any, message?: string): void;
+ /**
+ * Asserts that value >= atLeast
+ */
+ isAtLeast(value: any, atLeast: any, message?: string): void;
+ /**
+ * Asserts that value < below
+ */
+ isBelow(value: any, below: any, message?: string): void;
+ /**
+ * Asserts that value <= atMost
+ */
+ isAtMost(value: any, atMost: any, message?: string): void;
+ /**
+ * Asserts that value is true
+ */
+ isTrue(value: any, message?: string): void;
+ /**
+ * Asserts that value is not true
+ */
+ isNotTrue(value: any, message?: string): void;
+ /**
+ * Asserts that value is false
+ */
+ isFalse(value: any, message?: string): void;
+ /**
+ * Asserts that value is not false
+ */
+ isNotFalse(value: any, message?: string): void;
+ /**
+ * Asserts that value is null
+ */
+ isNull(value: any, message?: string): void;
+ /**
+ * Asserts that valus is not null
+ */
+ isNotNull(value: any, message?: string): void;
+ /**
+ * Asserts that value is NaN
+ */
+ isNaN(value: any, message?: string): void;
+ /**
+ * Asserts that value is not NaN
+ */
+ isNotNaN(value: any, message?: string): void;
+ /**
+ * Asserts that value is neither null nor undefined
+ */
+ exists(value: any, message?: string): void;
+ /**
+ * Asserts that value is either null or undefined
+ */
+ notExists(value: any, message?: string): void;
+ /**
+ * Asserts that value is undefined
+ */
+ isUndefined(value: any, message?: string): void;
+ /**
+ * Asserts that value is not undefined
+ */
+ isDefined(value: any, message?: string): void;
+ /**
+ * Asserts that value is a function
+ */
+ isFunction(value: any, message?: string): void;
+ /**
+ * Asserts that value is not a function
+ */
+ isNotFunction(value: any, message?: string): void;
+ /**
+ * Asserts that value is an object of type Object
+ */
+ isObject(value: any, message?: string): void;
+ /**
+ * Asserts that value is not an object of type Object
+ */
+ isNotObject(value: any, message?: string): void;
+ /**
+ * Asserts that value is an array
+ */
+ isArray(value: any, message?: string): void;
+ /**
+ * Asserts that value is not an array
+ */
+ isNotArray(value: any, message?: string): void;
+ /**
+ * Asserts that value is a string
+ */
+ isString(value: any, message?: string): void;
+ /**
+ * Asserts that value is not a string
+ */
+ isNotString(value: any, message?: string): void;
+ /**
+ * Asserts that value is a number
+ */
+ isNumber(value: any, message?: string): void;
+ /**
+ * Asserts that value is not a number
+ */
+ isNotNumber(value: any, message?: string): void;
+ /**
+ * Asserts that value is a finite number
+ */
+ isFinite(value: any, message?: string): void;
+ /**
+ * Asserts that value is a boolean
+ */
+ isBoolean(value: any, message?: string): void;
+ /**
+ * Asserts that value is not a boolean
+ */
+ isNotBoolean(value: any, message?: string): void;
+ /**
+ * Asserts that value's type is `type`
+ */
+ typeOf(value: any, type: PossibleTypes, message?: string): void;
+ typeOf(value: any, type: string, message?: string): void;
+ /**
+ * Assert that value's type is not `type`
+ */
+ notTypeOf(value: any, type: PossibleTypes, message?: string): void;
+ notTypeOf(value: any, type: string, message?: string): void;
+ /**
+ * Asserts that value is an instance of constructor
+ */
+ instanceOf(value: any, constructor: object, message?: string): void;
+ /**
+ * Asserts that value is not an instance of constructor
+ */
+ notInstanceOf(value: any, constructor: object, message?: string): void;
+ /**
+ * Asserts that expected includes inc
+ */
+ include(expected: T[], inc: T, message?: string): void;
+ include(expected: string, inc: string, message?: string): void;
+ /**
+ * Asserts that expected does not include inc
+ */
+ notInclude(expected: T[], inc: T, message?: string): void;
+ notInclude(expected: string, inc: string, message?: string): void;
+ /**
+ * Asserts that expected includes inc
+ */
+ deepInclude(expected: T[], inc: T, message?: string): void;
+ deepInclude(expected: string, inc: string, message?: string): void;
+ /**
+ * Asserts that expected does not include inc
+ */
+ notDeepInclude(expected: T[], inc: T, message?: string): void;
+ notDeepInclude(expected: string, inc: string, message?: string): void;
+ /**
+ * Asserts that expected includes inc
+ */
+ nestedInclude(expected: object, inc: object, message?: string): void;
+ /**
+ * Asserts that expected does not include inc
+ */
+ notNestedInclude(expected: object, inc: object, message?: string): void;
+ /**
+ * Assert that expected includes inc
+ */
+ deepNestedInclude(expected: object, inc: object, message?: string): void;
+ /**
+ * Assert that expected includes inc
+ */
+ notDeepNestedInclude(expected: object, inc: object, message?: string): void;
+ /**
+ * Assert that expected includes inc
+ */
+ ownInclude(expected: object, inc: object, message?: string): void;
+ /**
+ * Assert that expected does not include inc
+ */
+ notOwnInclude(expected: object, inc: object, message?: string): void;
+ /**
+ * Assert that expected includes inc
+ */
+ deepOwnInclude(expected: object, inc: object, message?: string): void;
+ /**
+ * Assert that expected does not include inc
+ */
+ notDeepOwnInclude(expected: object, inc: object, message?: string): void;
+ /**
+ * Asserts that expected matches the regular expression regExp
+ */
+ match(expected: any, regExp: RegExp, message?: string): void;
+ /**
+ * Asserts that expected does not match the regular expression regExp
+ */
+ notMatch(expected: any, regExp: RegExp, message?: string): void;
+ /**
+ * Asserts that object has a property named `property`
+ */
+ property(object: object, property: string, message?: string): void;
+ /**
+ * Asserts that object does not have a property named `property`
+ */
+ notProperty(object: object, property: string, message?: string): void;
+ /**
+ * Asserts that object has a property named `property` with value `value` (===)
+ */
+ propertyVal(object: object, property: string, value: any, message?: string): void;
+ /**
+ * Asserts that object does not have a property named `property` with value `value` (===)
+ */
+ notPropertyVal(object: object, property: string, value: any, message?: string): void;
+ /**
+ * Asserts that object has a property named `property` with a value `value`
+ */
+ deepPropertyVal(object: object, property: string, value: any, message?: string): void;
+ /**
+ * Asserts that object does not have a property named `property` with value `value`
+ */
+ notDeepPropertyVal(object: object, property: string, value: any, message?: string): void;
+ /**
+ * Asserts that object has an owned property named `property`
+ */
+ ownProperty(object: object, property: string, message?: string): void;
+ /**
+ * Asserts that object does not have an owned property named `property`
+ */
+ notOwnProperty(object: object, property: string, message?: string): void;
+ /**
+ * Asserts that object has an owned property named `property` with value `value`(===)
+ */
+ ownPropertyVal(object: object, property: string, value: any, message?: string): void;
+ /**
+ * Asserts that object does not have an owned property named `property` with value `value`(===)
+ */
+ notOwnPropertyVal(object: object, property: string, value: any, message?: string): void;
+ /**
+ * Asserts that object has an owned property named `property` with value `value`
+ */
+ deepOwnPropertyVal(object: object, property: string, value: any, message?: string): void;
+ /**
+ * Asserts that object does not have an owned property named `property` with value `value`(===)
+ */
+ notDeepOwnPropertyVal(object: object, property: string, value: any, message?: string): void;
+ /**
+ * Asserts that object has a property named `property`
+ */
+ nestedProperty(object: object, property: string, message?: string): void;
+ /**
+ * Asserts that object does not have a property named `property`
+ */
+ notNestedProperty(object: object, property: string, message?: string): void;
+ /**
+ * Asserts that object has a property named `property` with value `value`(===)
+ */
+ nestedPropertyVal(object: object, property: string, value: any, message?: string): void;
+ /**
+ * Asserts that object does not have a property named `property` with value `value`(===)
+ */
+ notNestedPropertyVal(object: object, property: string, value: any, message?: string): void;
+ /**
+ * Asserts that object has a property named `property` with value `value`
+ */
+ deepNestedPropertyVal(object: object, property: string, value: any, message?: string): void;
+ /**
+ * Asserts that object does not have a property named `property` with value `value`
+ */
+ notDeepNestedPropertyVal(object: object, property: string, value: any, message?: string): void;
+ /**
+ * Asserts that expected has a length property with value `length`
+ */
+ lengthOf(expected: any, length: number, message?: string): void;
+ /**
+ * Asserts that object has at least one key from `keys`
+ */
+ hasAnyKeys(object: object, keys: string | string[] | object, message?: string): void;
+ /**
+ * Asserts that object has all and only all of the keys provided
+ */
+ hasAllKeys(object: object, keys: string | string[] | object, message?: string): void;
+ /**
+ * Asserts that object has all the keys provided but maybe more
+ */
+ containsAllKeys(object: object, keys: string | string[] | object, message?: string): void;
+ /**
+ * Asserts that object does not have any provided key
+ */
+ doesNotHaveAnyKeys(object: object, keys: string | string[] | object, message?: string): void;
+ /**
+ * Asserts that object does not have all the keys provided
+ */
+ doesNotHaveAllKeys(object: object, keys: string | string[] | object, message?: string): void;
+ /**
+ * Asserts that object has at least one of the keys provided
+ */
+ hasAnyDeepKeys(object: object, keys: string | string[] | object, message?: string): void;
+ /**
+ * Asserts that object has all and only all of the keys provided
+ */
+ hasAllDeepKeys(object: object, keys: string | string[] | object, message?: string): void;
+ /**
+ * Asserts that object has all the keys provided but maybe more
+ */
+ containsAllDeepKeys(object: object, keys: string | string[] | object, message?: string): void;
+ /**
+ * Asserts that object does not have any provided key
+ */
+ doesNotHaveAnyDeepKeys(object: object, keys: string | string[] | object, message?: string): void;
+ /**
+ * Asserts that object does not have all the keys provided
+ */
+ doesNotHaveAllDeepKeys(object: object, keys: string | string[] | object, message?: string): void;
+ /**
+ * Asserts that a function or an async functions throws an error
+ */
+ throws(fn: () => void, errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): any;
+ throws(fn: () => Promise, errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): Promise;
+ /**
+ * Asserts that a function or an async functions throws an error
+ */
+ throw(fn: () => void, errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): any;
+ throw(fn: () => Promise, errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): Promise;
+ /**
+ * Asserts that a function or an async function does not throw an error
+ */
+ doesNotThrow(fn: () => Promise, errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): Promise;
+ doesNotThrow(fn: () => void, errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): any;
+ /**
+ * Compares two values using operator
+ */
+ operator(value: any, operator: string, val2: any, message?: string): void;
+ /**
+ * Asserts that actual is expected +/- delta
+ */
+ closeTo(actual: number, expected: number, delta: number, message?: string): void;
+ /**
+ * Asserts that actual is expect +/- delta
+ */
+ approximately(actual: number, expected: number, delta: number, message?: string): void;
+ /**
+ * Asserts that arrays have the same members in any order (===)
+ */
+ sameMembers(set1: any[], set2: any[], message?: string): void;
+ /**
+ * Asserts that arrays do not have the same members in any order (===)
+ */
+ notSameMembers(set1: any[], set2: any[], message?: string): void;
+ /**
+ * Asserts that arrays have the same members in any order
+ */
+ sameDeepMembers(set1: any[], set2: any[], message?: string): void;
+ /**
+ * Asserts that arrays do not have the same members in any order
+ */
+ notSameDeepMembers(set1: any[], set2: any[], message?: string): void;
+ /**
+ * Asserts that arrays have the same members in the same order (===)
+ */
+ sameOrderedMembers(set1: any[], set2: any[], message?: string): void;
+ /**
+ * Asserts that arrays do not have the same members in the same order (===)
+ */
+ notSameOrderedMembers(set1: any[], set2: any[], message?: string): void;
+ /**
+ * Asserts that arrays have the same members in the same order
+ */
+ sameDeepOrderedMembers(set1: any[], set2: any[], message?: string): void;
+ /**
+ * Asserts that arrays do not have the same members in the same order
+ */
+ notSameDeepOrderedMembers(set1: any[], set2: any[], message?: string): void;
+ /**
+ * Asserts that subset is included in superset in any order (===)
+ */
+ includeMembers(superset: any[], subset: any[], message?: string): void;
+ /**
+ * Asserts that subset is not included in superset in any order (===)
+ */
+ notIncludeMembers(superset: any[], subset: any[], message?: string): void;
+ /**
+ * Asserts that subset is included in superset in any order
+ */
+ includeDeepMembers(superset: any[], subset: any[], message?: string): void;
+ /**
+ * Asserts that subset is not included in superset in any order
+ */
+ notIncludeDeepMembers(superset: any[], subset: any[], message?: string): void;
+ /**
+ * Asserts that subset is included in superset in the same order (===)
+ */
+ includeOrderedMembers(superset: any[], subset: any[], message?: string): void;
+ /**
+ * Asserts that subset is not included in superset in the same order (===)
+ */
+ notIncludeOrderedMembers(superset: any[], subset: any[], message?: string): void;
+ /**
+ * Asserts that subset is included in superset in the same order
+ */
+ includeDeepOrderedMembers(superset: any[], subset: any[], message?: string): void;
+ /**
+ * Asserts that subset is not included in superset in the same order
+ */
+ notIncludeDeepOrderedMembers(superset: any[], subset: any[], message?: string): void;
+ /**
+ * Asserts that list includes inList
+ */
+ oneOf(inList: any, list: any[], message?: string): void;
+ /**
+ * Asserts that a function changes the value of a property
+ */
+ changes(fn: () => void, object: object, property: string, message?: string): void;
+ /**
+ * Asserts that a function changes the value of a property by delta
+ */
+ changesBy(fn: () => void, object: object, property: string, delta: number, message?: string): void;
+ /**
+ * Asserts that a function does not changes the value of a property
+ */
+ doesNotChange(fn: () => void, object: object, property: string, message?: string): void;
+ /**
+ * Asserts that a function does not change the value of a property or of a function’s return value by delta
+ */
+ changesButNotBy(fn: () => void, object: object, property: string, delta: number, message?: string): void;
+ /**
+ * Asserts that a function increases a numeric object property
+ */
+ increases(fn: () => void, object: object, property: string, message?: string): void;
+ /**
+ * Asserts that a function increases a numeric object property or a function’s return value by delta
+ */
+ increasesBy(fn: () => void, object: object, property: string, delta: number, message?: string): void;
+ /**
+ * Asserts that a function does not increase a numeric object property
+ */
+ doesNotIncrease(fn: () => void, object: object, property: string, message?: string): void;
+ /**
+ * Asserts that a function does not increase a numeric object property or function’s return value by delta
+ */
+ increasesButNotBy(fn: () => void, object: object, property: string, delta: number, message?: string): void;
+ /**
+ * Asserts that a function decreases the value of a property
+ */
+ decreases(fn: () => void, object: object, property: string, message?: string): void;
+ /**
+ * Asserts that a function decreases the value of a property by delta
+ */
+ decreasesBy(fn: () => void, object: object, property: string, delta: number, message?: string): void;
+ /**
+ * Asserts that a function does not decrease the value of a property
+ */
+ doesNotDecrease(fn: () => void, object: object, property: string, message?: string): void;
+ /**
+ * Asserts that a function does not decrease the value of a property or a function's return value by delta
+ */
+ doesNotDecreaseBy(fn: () => void, object: object, property: string, delta: number, message?: string): void;
+ /**
+ * Asserts that a function does not decreases a numeric object property or a function’s return value by delta
+ */
+ decreasesButNotBy(fn: () => void, object: object, property: string, delta: number, message?: string): void;
+ /**
+ * Throws an error if value is truthy
+ */
+ ifError(value: any): void;
+ /**
+ * Asserts that object is extensible
+ */
+ isExtensible(object: object, message?: string): void;
+ /**
+ * Asserts that object is extensible
+ */
+ extensible(object: object, message?: string): void;
+ /**
+ * Asserts that object is not extensible
+ */
+ isNotExtensible(object: object, message?: string): void;
+ /**
+ * Asserts that object is not extensible
+ */
+ notExtensible(object: object, message?: string): void;
+ /**
+ * Asserts that object is sealed
+ */
+ isSealed(object: object, message?: string): void;
+ /**
+ * Asserts that object is sealed
+ */
+ sealed(object: object, message?: string): void;
+ /**
+ * Asserts that object is not sealed
+ */
+ isNotSealed(object: object, message?: string): void;
+ /**
+ * Asserts that object is not sealed
+ */
+ notSealed(object: object, message?: string): void;
+ /**
+ * Asserts that object is frozen
+ */
+ isFrozen(object: object, message?: string): void;
+ /**
+ * Asserts that object is frozen
+ */
+ frozen(object: object, message?: string): void;
+ /**
+ * Asserts that object is not frozen
+ */
+ isNotFrozen(object: object, message?: string): void;
+ /**
+ * Asserts that object is not frozen
+ */
+ notFrozen(object: object, message?: string): void;
+ /**
+ * Asserts that value is empty
+ */
+ isEmpty(value: any, message?: string): void;
+ /**
+ * Asserts that value is empty
+ */
+ empty(value: any, message?: string): void;
+ /**
+ * Asserts that value is not empty
+ */
+ isNotEmpty(value: any, message?: string): void;
+ /**
+ * Asserts that value is not empty
+ */
+ notEmpty(value: any, message?: string): void;
+ }
+
+ interface ExpectFunction {
+ (value: shani.util.I.Spy, message?: string): MockAssertions;
+ (value: any, message?: string): Assertion;
+ fail(actual: any, expected: any, message?: string, operator?: any): void;
+ }
+
+ interface LanguageChains {
+ to: this;
+ be: this;
+ been: this;
+ is: this;
+ that: this;
+ which: this;
+ and: this;
+ has: this;
+ have: this;
+ with: this;
+ at: this;
+ of: this;
+ same: this;
+ but: this;
+ does: this;
+ }
+
+ interface Assertion extends LanguageChains {
+ /**
+ * Negates all following assertion in the chain
+ */
+ not: this;
+ /**
+ * Causes following assertions to use deep equality
+ */
+ deep: this;
+ /**
+ * Enables dot- and bracket-notation in following property and include assertions
+ */
+ nested: this;
+ /**
+ * Causes following property and incude assertions to ignore inherited properties
+ */
+ own: this;
+ /**
+ * Causes following members assertions to require that members be in the same order
+ */
+ ordered: this;
+ /**
+ * Causes following keys assertions to only require that the target have at least one of the given keys
+ */
+ any: this;
+ /**
+ * Causes following keys assertions to require that the target have all of the given keys
+ */
+ all: this;
+ /**
+ * Asserts that the target's type is `type`
+ */
+ a(type: PossibleTypes, message?: string): this;
+ a(type: string, message?: string): this;
+ /**
+ * Asserts that the target's type is `type`
+ */
+ an(type: PossibleTypes, message?: string): this;
+ an(type: string, message?: string): this;
+ /**
+ * Asserts that the target includes the given value
+ */
+ include(value: any, message?: string): this;
+ /**
+ * Asserts that the target includes the given value
+ */
+ includes(value: any, message?: string): this;
+ /**
+ * Asserts that the target contains the given value
+ */
+ contain(value: any, message?: string): this;
+ /**
+ * Asserts that the target contains the given value
+ */
+ contains(value: any, message?: string): this;
+ /**
+ * Asserts that the target is non-strictly equal to true
+ */
+ ok: this;
+ /**
+ * Asserts that the target is true
+ */
+ true: this;
+ /**
+ * Asserts that the target is false
+ */
+ false: this;
+ /**
+ * Asserts that the target is null
+ */
+ null: this;
+ /**
+ * Asserts that the target is undefined
+ */
+ undefined: this;
+ /**
+ * Asserts that the target is NaN
+ */
+ NaN: this;
+ /**
+ * Asserts that the target is neither null nor undefined
+ */
+ exist: this;
+ /**
+ * Asserts that the target is empty
+ */
+ empty: this;
+ /**
+ * Asserts that the target is an arguments object
+ */
+ arguments: this;
+ /**
+ * Asserts that the target is an arguments object
+ */
+ Arguments: this;
+ /**
+ * Asserts that the target is strictly equal to value(===)
+ */
+ equal(value: any, message?: string): this;
+ /**
+ * Asserts that the target is strictly equal to value(===)
+ */
+ equals(value: any, message?: string): this;
+ /**
+ * Asserts that the target is strictly equal to value(===)
+ */
+ eq(value: any, message?: string): this;
+ /**
+ * Asserts that the target is deeply equal to object
+ */
+ eql(object: any, message?: string): this;
+ /**
+ * Asserts that the target is deeply equal to object
+ */
+ eqls(object: any, message?: string): this;
+ /**
+ * Asserts that the target has the same length length and elements as array in the same order
+ */
+ eqlArray(array: any[], message?: string): this;
+ /**
+ * Asserts that target > n
+ */
+ above(n: number, message?: string): this;
+ /**
+ * Asserts that target > n
+ */
+ gt(n: number, message?: string): this;
+ /**
+ * Asserts that target > n
+ */
+ greaterThan(n: number, message?: string): this;
+ /**
+ * Asserts that target >= n
+ */
+ least(n: number, message?: string): this;
+ /**
+ * Asserts that target >= n
+ */
+ gte(n: number, message?: string): this;
+ /**
+ * Asserts that target < n
+ */
+ below(n: number, message?: string): this;
+ /**
+ * Asserts that target < n
+ */
+ lt(n: number, message?: string): this;
+ /**
+ * Asserts that target < n
+ */
+ lessThan(n: number, message?: string): this;
+ /**
+ * Asserts that target <= n
+ */
+ most(n: number, message?: string): this;
+ /**
+ * Asserts that target <= n
+ */
+ lte(n: number, message?: string): this;
+ /**
+ * Asserts that start <= target <= end
+ */
+ within(start: number, end: number, message?: string): this;
+ /**
+ * Asserts that the target is an instance of constructor
+ */
+ instanceof(constructor: object, message?: string): this;
+ /**
+ * Asserts that the target is an instance of constructor
+ */
+ instanceOf(constructor: object, message?: string): this;
+ /**
+ * Asserts that the target has a property name `name` with value `value`
+ */
+ property(name: string, value?: any, message?: string): this;
+ /**
+ * Asserts that the target has its own property name `name` with value `value`
+ */
+ ownProperty(name: string, value?: any, message?: string): this;
+ /**
+ * Asserts that the target has its own property name `name` with value `value`
+ */
+ haveOwnProperty(name: string, value?: any, message?: string): this;
+ /**
+ * Asserts that the target has its own property descriptor with name `name` and value `value`
+ */
+ ownPropertyDescriptor(name: string, descriptor?: object, message?: string): this;
+ /**
+ * Asserts that the target has its own property descriptor with name `name` and value `value`
+ */
+ haveOwnPropertyDescriptor(name: string, descriptor?: object, message?: string): this;
+ /**
+ * Asserts that the target's property length equal to n
+ */
+ length(n: number, message?: string): this;
+ /**
+ * Asserts that the target's property length equal to n
+ */
+ lengthOf(n: number, message?: string): this;
+ /**
+ * Asserts that the target matches the regular expression regExp
+ */
+ match(regExp: RegExp, message?: string): this;
+ /**
+ * Asserts that the target matches the regular expression regExp
+ */
+ matches(regExp: RegExp, message?: string): this;
+ /**
+ * Asserts that the target contains str as a substring
+ */
+ string(str: string, message?: string): this;
+ /**
+ * Assert that the target has the given keys
+ */
+ key(key: string | string[] | object): this;
+ key(...keys: string[]): this;
+ /**
+ * Assert that the target has the given keys
+ */
+ keys(key: string | string[] | object): this;
+ keys(...keys: string[]): this;
+ /**
+ * Assert that the target throws an error
+ */
+ throw(errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): this;
+ /**
+ * Assert that the target throws an error
+ */
+ throws(errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): this;
+ /**
+ * Assert that the target throws an error
+ */
+ Throw(errorLike?: Error, errMsgMatcher?: string | RegExp): this;
+ /**
+ * Assert that the target has a method with name `method`. For functions checks the prototype
+ */
+ respondTo(method: string, message?: string): this;
+ /**
+ * Assert that the target has a method with name `method`. For functions checks the prototype
+ */
+ respondsTo(method: string, message?: string): this;
+ /**
+ * Makes respondsTo behave like the target is not a function
+ */
+ itself: this;
+ /**
+ * Asserts that matches returns a truthy value with the target as the first argument
+ */
+ satisfy(matcher: () => boolean, message?: string): this;
+ /**
+ * Asserts that matches returns a truthy value with the target as the first argument
+ */
+ satisfies(matcher: () => boolean, message?: string): this;
+ /**
+ * Asserts that the target is expected +/- delta
+ */
+ closeTo(expected: number, delta: number, message?: string): this;
+ /**
+ * Asserts that the target is expected +/- delta
+ */
+ approximately(expected: number, delta: number, message?: string): this;
+ /**
+ * Asserts that the target array has the same members as the given
+ */
+ members(set: any[], message?: string): this;
+ /**
+ * Asserts that the target is the member of list
+ */
+ oneOf(list: any[], message?: string): this;
+ /**
+ * Asserts that fn returns a different value after the target's invokation than before
+ */
+ change(fn: () => any, message?: string): this;
+ /**
+ * Asserts that the target's invokation changes subject's property
+ */
+ change(subject: object, property: string, message?: string): this;
+ /**
+ * Asserts that fn returns a different value after the target's invokation than before
+ */
+ changes(fn: () => any, message?: string): this;
+ /**
+ * Asserts that the target's invokation changes subject's property
+ */
+ changes(subject: object, property: string, message?: string): this;
+ /**
+ * Asserts that fn returns a greater number after the target's invokation than before
+ */
+ increase(fn: () => number, message?: string): this;
+ /**
+ * Asserts that the target's invokation increases subject's property
+ */
+ increase(subject: object, property?: string, message?: string): this;
+ /**
+ * Asserts that fn returns a greater number after the target's invokation than before
+ */
+ increases(fn: () => number, message?: string): this;
+ /**
+ * Asserts that the target's invokation increases subject's property
+ */
+ increases(subject: object, property?: string, message?: string): this;
+ /**
+ * Asserts that fn returns a lesser number after the target's invokation than before
+ */
+ decrease(fn: () => number, message?: string): this;
+ /**
+ * Asserts that the target's invokation decreases subject's property
+ */
+ decrease(subject: object, property?: string, message?: string): this;
+ /**
+ * Asserts that fn returns a lesser number after the target's invokation than before
+ */
+ decreases(fn: () => number, message?: string): this;
+ /**
+ * Asserts that the target's invokation decreases subject's property
+ */
+ decreases(subject: object, property?: string, message?: string): this;
+ /**
+ * Asserts that the value was decreased/increased by delta
+ */
+ by(delta: number, message?: string): this;
+ /**
+ * Asserts that the target is extensible
+ */
+ extensible: this;
+ /**
+ * Asserts that the target is sealed
+ */
+ sealed: this;
+ /**
+ * Asserts that the target is frozen
+ */
+ frozen: this;
+ /**
+ * Asserts that the target is a finite number
+ */
+ finite: this;
+ }
+
+ interface MockAssertions extends Assertion {
+ /**
+ * Asserts that the spy has been called
+ */
+ called: this;
+ /**
+ * Asserts that the spy has been called n times
+ */
+ callCount(n: number): this;
+ /**
+ * Asserts that the spy has been called once
+ */
+ calledOnce: this;
+ /**
+ * Asserts that the spy has been called twice
+ */
+ calledTwice: this;
+ /**
+ * Asserts that the spy has been been called with `new`
+ */
+ calledThrice: this;
+ /**
+ * Asserts that the spy has been called before anotherSpy
+ */
+ calledBefore(anotherSpy: shani.util.I.Spy): this;
+ /**
+ * Asserts that the spy has been called after anotherSpy
+ */
+ calledAfter(anotherSpy: shani.util.I.Spy): this;
+ /**
+ * Asserts that the spy has been called immediately before anotherSpy
+ */
+ calledImmediatelyBefore(anotherSpy: shani.util.I.Spy): this;
+ /**
+ * Asserts that the spy has been called immediately after anotherSpy
+ */
+ calledImmediatelyAfter(anotherSpy: shani.util.I.Spy): this;
+ /**
+ * Asserts that the spy has been called with context as this value
+ */
+ calledOn(context: object): this;
+ /**
+ * Asserts that the spy has been called with the given arguments
+ */
+ calledWith(...args: any[]): this;
+ /**
+ * Asserts that the spy has been called exactly with the given arguments
+ */
+ calledWithExactly(...args: any[]): this;
+ /**
+ * Asserts that the spy has been called with matching arguments
+ */
+ calledWithMatch(...args: any[]): this;
+ /**
+ * Asserts that the spy returned value
+ */
+ returned(value: any): this;
+ /**
+ * Asserts that the spy threw error
+ */
+ thrown(error: any): this;
+ /**
+ * Asserts that the spy threw error
+ */
+ threw(error: any): this;
+ }
}
- interface Config {
- /**
- * Include stack in Assertion error message
- */
- includeStack: boolean;
- /**
- * Include `showDiff` flag in the thrown errors
- */
- showDiff: boolean;
- /**
- * Length threshold for actual and expected values in assertion errors
- */
- truncateThreshold: number;
- /**
- * use Proxy to throw an error when a non-existent property is read
- */
- useProxy: boolean;
- /**
- * properties that should be ignored instead of throwing an error if they do not exist on the assertion
- */
- proxyExcludedKeys: string[];
+ class AssertionError extends x.Exception {
+ constructor(message?: string, props?: object, ssf?: object)
}
- type PossibleTypes = adone.util.I.PossibleTypes | "array";
-
- type UseFunction = (fn: () => void) => assertion;
-
- type LoadInterfaceFunction = () => assertion;
-
- interface AssertFunction {
- /**
- * Asserts that value is truthy
- */
- (value: any, message?: string): void;
- /**
- * Throws an AssertionError, like node.js
- */
- fail(actual?: any, expected?: any, message?: string, operator?: any): void;
- /**
- * Asserts that value is truthy
- */
- isOk(value: any, message?: string): void;
- /**
- * Asserts that value is truthy
- */
- ok(value: any, message?: string): void;
- /**
- * Asserts that value is falsy
- */
- isNotOk(value: any, message?: string): void;
- /**
- * Asserts that value is falsy
- */
- notOk(value: any, message?: string): void;
- /**
- * Asserts non-strict equality
- */
- equal(actual: any, expected: any, message?: string): void;
- /**
- * Asserts non-strict inequality
- */
- notEqual(actual: any, expected: any, message?: string): void;
- /**
- * Asserts strict equality
- */
- strictEqual(actual: any, expected: any, message?: string): void;
- /**
- * Asserts strict inequality
- */
- notStrictEqual(actual: any, expected: any, message?: string): void;
- /**
- * Asserts that actual is deeply equal to expected
- */
- deepEqual(actual: any, expected: any, message?: string): void;
- /**
- * Asserts that actual is deeply equal to expected
- */
- deepStrictEqual(actual: any, expected: any, message?: string): void;
- /**
- * Asserts that actual and expected have the same length and the same members (===)
- */
- equalArrays(actual: any[], expected: any[], message?: string): void;
- /**
- * Asserts that actual is not deeply equal to expected
- */
- notDeepEqual(actual: any, expected: any, message?: string): void;
- /**
- * Asserts that value > above
- */
- isAbove(value: any, above: any, message?: string): void;
- /**
- * Asserts that value >= atLeast
- */
- isAtLeast(value: any, atLeast: any, message?: string): void;
- /**
- * Asserts that value < below
- */
- isBelow(value: any, below: any, message?: string): void;
- /**
- * Asserts that value <= atMost
- */
- isAtMost(value: any, atMost: any, message?: string): void;
- /**
- * Asserts that value is true
- */
- isTrue(value: any, message?: string): void;
- /**
- * Asserts that value is not true
- */
- isNotTrue(value: any, message?: string): void;
- /**
- * Asserts that value is false
- */
- isFalse(value: any, message?: string): void;
- /**
- * Asserts that value is not false
- */
- isNotFalse(value: any, message?: string): void;
- /**
- * Asserts that value is null
- */
- isNull(value: any, message?: string): void;
- /**
- * Asserts that valus is not null
- */
- isNotNull(value: any, message?: string): void;
- /**
- * Asserts that value is NaN
- */
- isNaN(value: any, message?: string): void;
- /**
- * Asserts that value is not NaN
- */
- isNotNaN(value: any, message?: string): void;
- /**
- * Asserts that value is neither null nor undefined
- */
- exists(value: any, message?: string): void;
- /**
- * Asserts that value is either null or undefined
- */
- notExists(value: any, message?: string): void;
- /**
- * Asserts that value is undefined
- */
- isUndefined(value: any, message?: string): void;
- /**
- * Asserts that value is not undefined
- */
- isDefined(value: any, message?: string): void;
- /**
- * Asserts that value is a function
- */
- isFunction(value: any, message?: string): void;
- /**
- * Asserts that value is not a function
- */
- isNotFunction(value: any, message?: string): void;
- /**
- * Asserts that value is an object of type Object
- */
- isObject(value: any, message?: string): void;
- /**
- * Asserts that value is not an object of type Object
- */
- isNotObject(value: any, message?: string): void;
- /**
- * Asserts that value is an array
- */
- isArray(value: any, message?: string): void;
- /**
- * Asserts that value is not an array
- */
- isNotArray(value: any, message?: string): void;
- /**
- * Asserts that value is a string
- */
- isString(value: any, message?: string): void;
- /**
- * Asserts that value is not a string
- */
- isNotString(value: any, message?: string): void;
- /**
- * Asserts that value is a number
- */
- isNumber(value: any, message?: string): void;
- /**
- * Asserts that value is not a number
- */
- isNotNumber(value: any, message?: string): void;
- /**
- * Asserts that value is a finite number
- */
- isFinite(value: any, message?: string): void;
- /**
- * Asserts that value is a boolean
- */
- isBoolean(value: any, message?: string): void;
- /**
- * Asserts that value is not a boolean
- */
- isNotBoolean(value: any, message?: string): void;
- /**
- * Asserts that value's type is `type`
- */
- typeOf(value: any, type: I.PossibleTypes, message?: string): void;
- typeOf(value: any, type: string, message?: string): void;
- /**
- * Assert that value's type is not `type`
- */
- notTypeOf(value: any, type: I.PossibleTypes, message?: string): void;
- notTypeOf(value: any, type: string, message?: string): void;
- /**
- * Asserts that value is an instance of constructor
- */
- instanceOf(value: any, constructor: object, message?: string): void;
- /**
- * Asserts that value is not an instance of constructor
- */
- notInstanceOf(value: any, constructor: object, message?: string): void;
- /**
- * Asserts that expected includes inc
- */
- include(expected: T[], inc: T, message?: string): void;
- include(expected: string, inc: string, message?: string): void;
- /**
- * Asserts that expected does not include inc
- */
- notInclude(expected: T[], inc: T, message?: string): void;
- notInclude(expected: string, inc: string, message?: string): void;
- /**
- * Asserts that expected includes inc
- */
- deepInclude(expected: T[], inc: T, message?: string): void;
- deepInclude(expected: string, inc: string, message?: string): void;
- /**
- * Asserts that expected does not include inc
- */
- notDeepInclude(expected: T[], inc: T, message?: string): void;
- notDeepInclude(expected: string, inc: string, message?: string): void;
- /**
- * Asserts that expected includes inc
- */
- nestedInclude(expected: object, inc: object, message?: string): void;
- /**
- * Asserts that expected does not include inc
- */
- notNestedInclude(expected: object, inc: object, message?: string): void;
- /**
- * Assert that expected includes inc
- */
- deepNestedInclude(expected: object, inc: object, message?: string): void;
- /**
- * Assert that expected includes inc
- */
- notDeepNestedInclude(expected: object, inc: object, message?: string): void;
- /**
- * Assert that expected includes inc
- */
- ownInclude(expected: object, inc: object, message?: string): void;
- /**
- * Assert that expected does not include inc
- */
- notOwnInclude(expected: object, inc: object, message?: string): void;
- /**
- * Assert that expected includes inc
- */
- deepOwnInclude(expected: object, inc: object, message?: string): void;
- /**
- * Assert that expected does not include inc
- */
- notDeepOwnInclude(expected: object, inc: object, message?: string): void;
- /**
- * Asserts that expected matches the regular expression regExp
- */
- match(expected: any, regExp: RegExp, message?: string): void;
- /**
- * Asserts that expected does not match the regular expression regExp
- */
- notMatch(expected: any, regExp: RegExp, message?: string): void;
- /**
- * Asserts that object has a property named `property`
- */
- property(object: object, property: string, message?: string): void;
- /**
- * Asserts that object does not have a property named `property`
- */
- notProperty(object: object, property: string, message?: string): void;
- /**
- * Asserts that object has a property named `property` with value `value` (===)
- */
- propertyVal(object: object, property: string, value: any, message?: string): void;
- /**
- * Asserts that object does not have a property named `property` with value `value` (===)
- */
- notPropertyVal(object: object, property: string, value: any, message?: string): void;
- /**
- * Asserts that object has a property named `property` with a value `value`
- */
- deepPropertyVal(object: object, property: string, value: any, message?: string): void;
- /**
- * Asserts that object does not have a property named `property` with value `value`
- */
- notDeepPropertyVal(object: object, property: string, value: any, message?: string): void;
- /**
- * Asserts that object has an owned property named `property`
- */
- ownProperty(object: object, property: string, message?: string): void;
- /**
- * Asserts that object does not have an owned property named `property`
- */
- notOwnProperty(object: object, property: string, message?: string): void;
- /**
- * Asserts that object has an owned property named `property` with value `value`(===)
- */
- ownPropertyVal(object: object, property: string, value: any, message?: string): void;
- /**
- * Asserts that object does not have an owned property named `property` with value `value`(===)
- */
- notOwnPropertyVal(object: object, property: string, value: any, message?: string): void;
- /**
- * Asserts that object has an owned property named `property` with value `value`
- */
- deepOwnPropertyVal(object: object, property: string, value: any, message?: string): void;
- /**
- * Asserts that object does not have an owned property named `property` with value `value`(===)
- */
- notDeepOwnPropertyVal(object: object, property: string, value: any, message?: string): void;
- /**
- * Asserts that object has a property named `property`
- */
- nestedProperty(object: object, property: string, message?: string): void;
- /**
- * Asserts that object does not have a property named `property`
- */
- notNestedProperty(object: object, property: string, message?: string): void;
- /**
- * Asserts that object has a property named `property` with value `value`(===)
- */
- nestedPropertyVal(object: object, property: string, value: any, message?: string): void;
- /**
- * Asserts that object does not have a property named `property` with value `value`(===)
- */
- notNestedPropertyVal(object: object, property: string, value: any, message?: string): void;
- /**
- * Asserts that object has a property named `property` with value `value`
- */
- deepNestedPropertyVal(object: object, property: string, value: any, message?: string): void;
- /**
- * Asserts that object does not have a property named `property` with value `value`
- */
- notDeepNestedPropertyVal(object: object, property: string, value: any, message?: string): void;
- /**
- * Asserts that expected has a length property with value `length`
- */
- lengthOf(expected: any, length: number, message?: string): void;
- /**
- * Asserts that object has at least one key from `keys`
- */
- hasAnyKeys(object: object, keys: string | string[] | object, message?: string): void;
- /**
- * Asserts that object has all and only all of the keys provided
- */
- hasAllKeys(object: object, keys: string | string[] | object, message?: string): void;
- /**
- * Asserts that object has all the keys provided but maybe more
- */
- containsAllKeys(object: object, keys: string | string[] | object, message?: string): void;
- /**
- * Asserts that object does not have any provided key
- */
- doesNotHaveAnyKeys(object: object, keys: string | string[] | object, message?: string): void;
- /**
- * Asserts that object does not have all the keys provided
- */
- doesNotHaveAllKeys(object: object, keys: string | string[] | object, message?: string): void;
- /**
- * Asserts that object has at least one of the keys provided
- */
- hasAnyDeepKeys(object: object, keys: string | string[] | object, message?: string): void;
- /**
- * Asserts that object has all and only all of the keys provided
- */
- hasAllDeepKeys(object: object, keys: string | string[] | object, message?: string): void;
- /**
- * Asserts that object has all the keys provided but maybe more
- */
- containsAllDeepKeys(object: object, keys: string | string[] | object, message?: string): void;
- /**
- * Asserts that object does not have any provided key
- */
- doesNotHaveAnyDeepKeys(object: object, keys: string | string[] | object, message?: string): void;
- /**
- * Asserts that object does not have all the keys provided
- */
- doesNotHaveAllDeepKeys(object: object, keys: string | string[] | object, message?: string): void;
- /**
- * Asserts that a function or an async functions throws an error
- */
- throws(fn: () => void, errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): any;
- throws(fn: () => Promise, errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): Promise;
- /**
- * Asserts that a function or an async functions throws an error
- */
- throw(fn: () => void, errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): any;
- throw(fn: () => Promise, errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): Promise;
- /**
- * Asserts that a function or an async function does not throw an error
- */
- doesNotThrow(fn: () => Promise, errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): Promise;
- doesNotThrow(fn: () => void, errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): any;
- /**
- * Compares two values using operator
- */
- operator(value: any, operator: string, val2: any, message?: string): void;
- /**
- * Asserts that actual is expected +/- delta
- */
- closeTo(actual: number, expected: number, delta: number, message?: string): void;
- /**
- * Asserts that actual is expect +/- delta
- */
- approximately(actual: number, expected: number, delta: number, message?: string): void;
- /**
- * Asserts that arrays have the same members in any order (===)
- */
- sameMembers(set1: any[], set2: any[], message?: string): void;
- /**
- * Asserts that arrays do not have the same members in any order (===)
- */
- notSameMembers(set1: any[], set2: any[], message?: string): void;
- /**
- * Asserts that arrays have the same members in any order
- */
- sameDeepMembers(set1: any[], set2: any[], message?: string): void;
- /**
- * Asserts that arrays do not have the same members in any order
- */
- notSameDeepMembers(set1: any[], set2: any[], message?: string): void;
- /**
- * Asserts that arrays have the same members in the same order (===)
- */
- sameOrderedMembers(set1: any[], set2: any[], message?: string): void;
- /**
- * Asserts that arrays do not have the same members in the same order (===)
- */
- notSameOrderedMembers(set1: any[], set2: any[], message?: string): void;
- /**
- * Asserts that arrays have the same members in the same order
- */
- sameDeepOrderedMembers(set1: any[], set2: any[], message?: string): void;
- /**
- * Asserts that arrays do not have the same members in the same order
- */
- notSameDeepOrderedMembers(set1: any[], set2: any[], message?: string): void;
- /**
- * Asserts that subset is included in superset in any order (===)
- */
- includeMembers(superset: any[], subset: any[], message?: string): void;
- /**
- * Asserts that subset is not included in superset in any order (===)
- */
- notIncludeMembers(superset: any[], subset: any[], message?: string): void;
- /**
- * Asserts that subset is included in superset in any order
- */
- includeDeepMembers(superset: any[], subset: any[], message?: string): void;
- /**
- * Asserts that subset is not included in superset in any order
- */
- notIncludeDeepMembers(superset: any[], subset: any[], message?: string): void;
- /**
- * Asserts that subset is included in superset in the same order (===)
- */
- includeOrderedMembers(superset: any[], subset: any[], message?: string): void;
- /**
- * Asserts that subset is not included in superset in the same order (===)
- */
- notIncludeOrderedMembers(superset: any[], subset: any[], message?: string): void;
- /**
- * Asserts that subset is included in superset in the same order
- */
- includeDeepOrderedMembers(superset: any[], subset: any[], message?: string): void;
- /**
- * Asserts that subset is not included in superset in the same order
- */
- notIncludeDeepOrderedMembers(superset: any[], subset: any[], message?: string): void;
- /**
- * Asserts that list includes inList
- */
- oneOf(inList: any, list: any[], message?: string): void;
- /**
- * Asserts that a function changes the value of a property
- */
- changes(fn: () => void, object: object, property: string, message?: string): void;
- /**
- * Asserts that a function changes the value of a property by delta
- */
- changesBy(fn: () => void, object: object, property: string, delta: number, message?: string): void;
- /**
- * Asserts that a function does not changes the value of a property
- */
- doesNotChange(fn: () => void, object: object, property: string, message?: string): void;
- /**
- * Asserts that a function does not change the value of a property or of a function’s return value by delta
- */
- changesButNotBy(fn: () => void, object: object, property: string, delta: number, message?: string): void;
- /**
- * Asserts that a function increases a numeric object property
- */
- increases(fn: () => void, object: object, property: string, message?: string): void;
- /**
- * Asserts that a function increases a numeric object property or a function’s return value by delta
- */
- increasesBy(fn: () => void, object: object, property: string, delta: number, message?: string): void;
- /**
- * Asserts that a function does not increase a numeric object property
- */
- doesNotIncrease(fn: () => void, object: object, property: string, message?: string): void;
- /**
- * Asserts that a function does not increase a numeric object property or function’s return value by delta
- */
- increasesButNotBy(fn: () => void, object: object, property: string, delta: number, message?: string): void;
- /**
- * Asserts that a function decreases the value of a property
- */
- decreases(fn: () => void, object: object, property: string, message?: string): void;
- /**
- * Asserts that a function decreases the value of a property by delta
- */
- decreasesBy(fn: () => void, object: object, property: string, delta: number, message?: string): void;
- /**
- * Asserts that a function does not decrease the value of a property
- */
- doesNotDecrease(fn: () => void, object: object, property: string, message?: string): void;
- /**
- * Asserts that a function does not decrease the value of a property or a function's return value by delta
- */
- doesNotDecreaseBy(fn: () => void, object: object, property: string, delta: number, message?: string): void;
- /**
- * Asserts that a function does not decreases a numeric object property or a function’s return value by delta
- */
- decreasesButNotBy(fn: () => void, object: object, property: string, delta: number, message?: string): void;
- /**
- * Throws an error if value is truthy
- */
- ifError(value: any): void;
- /**
- * Asserts that object is extensible
- */
- isExtensible(object: object, message?: string): void;
- /**
- * Asserts that object is extensible
- */
- extensible(object: object, message?: string): void;
- /**
- * Asserts that object is not extensible
- */
- isNotExtensible(object: object, message?: string): void;
- /**
- * Asserts that object is not extensible
- */
- notExtensible(object: object, message?: string): void;
- /**
- * Asserts that object is sealed
- */
- isSealed(object: object, message?: string): void;
- /**
- * Asserts that object is sealed
- */
- sealed(object: object, message?: string): void;
- /**
- * Asserts that object is not sealed
- */
- isNotSealed(object: object, message?: string): void;
- /**
- * Asserts that object is not sealed
- */
- notSealed(object: object, message?: string): void;
- /**
- * Asserts that object is frozen
- */
- isFrozen(object: object, message?: string): void;
- /**
- * Asserts that object is frozen
- */
- frozen(object: object, message?: string): void;
- /**
- * Asserts that object is not frozen
- */
- isNotFrozen(object: object, message?: string): void;
- /**
- * Asserts that object is not frozen
- */
- notFrozen(object: object, message?: string): void;
- /**
- * Asserts that value is empty
- */
- isEmpty(value: any, message?: string): void;
- /**
- * Asserts that value is empty
- */
- empty(value: any, message?: string): void;
- /**
- * Asserts that value is not empty
- */
- isNotEmpty(value: any, message?: string): void;
- /**
- * Asserts that value is not empty
- */
- notEmpty(value: any, message?: string): void;
- }
-
- interface ExpectFunction {
- (value: adone.shani.util.I.Spy, message?: string): MockAssertions;
- (value: any, message?: string): Assertion;
- fail(actual: any, expected: any, message?: string, operator?: any): void;
- }
-
- interface LanguageChains {
- to: this;
- be: this;
- been: this;
- is: this;
- that: this;
- which: this;
- and: this;
- has: this;
- have: this;
- with: this;
- at: this;
- of: this;
- same: this;
- but: this;
- does: this;
- }
-
- interface Assertion extends LanguageChains {
- /**
- * Negates all following assertion in the chain
- */
- not: this;
- /**
- * Causes following assertions to use deep equality
- */
- deep: this;
- /**
- * Enables dot- and bracket-notation in following property and include assertions
- */
- nested: this;
- /**
- * Causes following property and incude assertions to ignore inherited properties
- */
- own: this;
- /**
- * Causes following members assertions to require that members be in the same order
- */
- ordered: this;
- /**
- * Causes following keys assertions to only require that the target have at least one of the given keys
- */
- any: this;
- /**
- * Causes following keys assertions to require that the target have all of the given keys
- */
- all: this;
- /**
- * Asserts that the target's type is `type`
- */
- a(type: I.PossibleTypes, message?: string): this;
- a(type: string, message?: string): this;
- /**
- * Asserts that the target's type is `type`
- */
- an(type: I.PossibleTypes, message?: string): this;
- an(type: string, message?: string): this;
- /**
- * Asserts that the target includes the given value
- */
- include(value: any, message?: string): this;
- /**
- * Asserts that the target includes the given value
- */
- includes(value: any, message?: string): this;
- /**
- * Asserts that the target contains the given value
- */
- contain(value: any, message?: string): this;
- /**
- * Asserts that the target contains the given value
- */
- contains(value: any, message?: string): this;
- /**
- * Asserts that the target is non-strictly equal to true
- */
- ok: this;
- /**
- * Asserts that the target is true
- */
- true: this;
- /**
- * Asserts that the target is false
- */
- false: this;
- /**
- * Asserts that the target is null
- */
- null: this;
- /**
- * Asserts that the target is undefined
- */
- undefined: this;
- /**
- * Asserts that the target is NaN
- */
- NaN: this;
- /**
- * Asserts that the target is neither null nor undefined
- */
- exist: this;
- /**
- * Asserts that the target is empty
- */
- empty: this;
- /**
- * Asserts that the target is an arguments object
- */
- arguments: this;
- /**
- * Asserts that the target is an arguments object
- */
- Arguments: this;
- /**
- * Asserts that the target is strictly equal to value(===)
- */
- equal(value: any, message?: string): this;
- /**
- * Asserts that the target is strictly equal to value(===)
- */
- equals(value: any, message?: string): this;
- /**
- * Asserts that the target is strictly equal to value(===)
- */
- eq(value: any, message?: string): this;
- /**
- * Asserts that the target is deeply equal to object
- */
- eql(object: any, message?: string): this;
- /**
- * Asserts that the target is deeply equal to object
- */
- eqls(object: any, message?: string): this;
- /**
- * Asserts that the target has the same length length and elements as array in the same order
- */
- eqlArray(array: any[], message?: string): this;
- /**
- * Asserts that target > n
- */
- above(n: number, message?: string): this;
- /**
- * Asserts that target > n
- */
- gt(n: number, message?: string): this;
- /**
- * Asserts that target > n
- */
- greaterThan(n: number, message?: string): this;
- /**
- * Asserts that target >= n
- */
- least(n: number, message?: string): this;
- /**
- * Asserts that target >= n
- */
- gte(n: number, message?: string): this;
- /**
- * Asserts that target < n
- */
- below(n: number, message?: string): this;
- /**
- * Asserts that target < n
- */
- lt(n: number, message?: string): this;
- /**
- * Asserts that target < n
- */
- lessThan(n: number, message?: string): this;
- /**
- * Asserts that target <= n
- */
- most(n: number, message?: string): this;
- /**
- * Asserts that target <= n
- */
- lte(n: number, message?: string): this;
- /**
- * Asserts that start <= target <= end
- */
- within(start: number, end: number, message?: string): this;
- /**
- * Asserts that the target is an instance of constructor
- */
- instanceof(constructor: object, message?: string): this;
- /**
- * Asserts that the target is an instance of constructor
- */
- instanceOf(constructor: object, message?: string): this;
- /**
- * Asserts that the target has a property name `name` with value `value`
- */
- property(name: string, value?: any, message?: string): this;
- /**
- * Asserts that the target has its own property name `name` with value `value`
- */
- ownProperty(name: string, value?: any, message?: string): this;
- /**
- * Asserts that the target has its own property name `name` with value `value`
- */
- haveOwnProperty(name: string, value?: any, message?: string): this;
- /**
- * Asserts that the target has its own property descriptor with name `name` and value `value`
- */
- ownPropertyDescriptor(name: string, descriptor?: object, message?: string): this;
- /**
- * Asserts that the target has its own property descriptor with name `name` and value `value`
- */
- haveOwnPropertyDescriptor(name: string, descriptor?: object, message?: string): this;
- /**
- * Asserts that the target's property length equal to n
- */
- length(n: number, message?: string): this;
- /**
- * Asserts that the target's property length equal to n
- */
- lengthOf(n: number, message?: string): this;
- /**
- * Asserts that the target matches the regular expression regExp
- */
- match(regExp: RegExp, message?: string): this;
- /**
- * Asserts that the target matches the regular expression regExp
- */
- matches(regExp: RegExp, message?: string): this;
- /**
- * Asserts that the target contains str as a substring
- */
- string(str: string, message?: string): this;
- /**
- * Assert that the target has the given keys
- */
- key(key: string | string[] | object): this;
- key(...keys: string[]): this;
- /**
- * Assert that the target has the given keys
- */
- keys(key: string | string[] | object): this;
- keys(...keys: string[]): this;
- /**
- * Assert that the target throws an error
- */
- throw(errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): this;
- /**
- * Assert that the target throws an error
- */
- throws(errorLike?: object, errMsgMatcher?: string | RegExp, message?: string): this;
- /**
- * Assert that the target throws an error
- */
- Throw(errorLike?: Error, errMsgMatcher?: string | RegExp): this;
- /**
- * Assert that the target has a method with name `method`. For functions checks the prototype
- */
- respondTo(method: string, message?: string): this;
- /**
- * Assert that the target has a method with name `method`. For functions checks the prototype
- */
- respondsTo(method: string, message?: string): this;
- /**
- * Makes respondsTo behave like the target is not a function
- */
- itself: this;
- /**
- * Asserts that matches returns a truthy value with the target as the first argument
- */
- satisfy(matcher: () => boolean, message?: string): this;
- /**
- * Asserts that matches returns a truthy value with the target as the first argument
- */
- satisfies(matcher: () => boolean, message?: string): this;
- /**
- * Asserts that the target is expected +/- delta
- */
- closeTo(expected: number, delta: number, message?: string): this;
- /**
- * Asserts that the target is expected +/- delta
- */
- approximately(expected: number, delta: number, message?: string): this;
- /**
- * Asserts that the target array has the same members as the given
- */
- members(set: any[], message?: string): this;
- /**
- * Asserts that the target is the member of list
- */
- oneOf(list: any[], message?: string): this;
- /**
- * Asserts that fn returns a different value after the target's invokation than before
- */
- change(fn: () => any, message?: string): this;
- /**
- * Asserts that the target's invokation changes subject's property
- */
- change(subject: object, property: string, message?: string): this;
- /**
- * Asserts that fn returns a different value after the target's invokation than before
- */
- changes(fn: () => any, message?: string): this;
- /**
- * Asserts that the target's invokation changes subject's property
- */
- changes(subject: object, property: string, message?: string): this;
- /**
- * Asserts that fn returns a greater number after the target's invokation than before
- */
- increase(fn: () => number, message?: string): this;
- /**
- * Asserts that the target's invokation increases subject's property
- */
- increase(subject: object, property?: string, message?: string): this;
- /**
- * Asserts that fn returns a greater number after the target's invokation than before
- */
- increases(fn: () => number, message?: string): this;
- /**
- * Asserts that the target's invokation increases subject's property
- */
- increases(subject: object, property?: string, message?: string): this;
- /**
- * Asserts that fn returns a lesser number after the target's invokation than before
- */
- decrease(fn: () => number, message?: string): this;
- /**
- * Asserts that the target's invokation decreases subject's property
- */
- decrease(subject: object, property?: string, message?: string): this;
- /**
- * Asserts that fn returns a lesser number after the target's invokation than before
- */
- decreases(fn: () => number, message?: string): this;
- /**
- * Asserts that the target's invokation decreases subject's property
- */
- decreases(subject: object, property?: string, message?: string): this;
- /**
- * Asserts that the value was decreased/increased by delta
- */
- by(delta: number, message?: string): this;
- /**
- * Asserts that the target is extensible
- */
- extensible: this;
- /**
- * Asserts that the target is sealed
- */
- sealed: this;
- /**
- * Asserts that the target is frozen
- */
- frozen: this;
- /**
- * Asserts that the target is a finite number
- */
- finite: this;
- }
-
- interface MockAssertions extends Assertion {
- /**
- * Asserts that the spy has been called
- */
- called: this;
- /**
- * Asserts that the spy has been called n times
- */
- callCount(n: number): this;
- /**
- * Asserts that the spy has been called once
- */
- calledOnce: this;
- /**
- * Asserts that the spy has been called twice
- */
- calledTwice: this;
- /**
- * Asserts that the spy has been been called with `new`
- */
- calledThrice: this;
- /**
- * Asserts that the spy has been called before anotherSpy
- */
- calledBefore(anotherSpy: adone.shani.util.I.Spy): this;
- /**
- * Asserts that the spy has been called after anotherSpy
- */
- calledAfter(anotherSpy: adone.shani.util.I.Spy): this;
- /**
- * Asserts that the spy has been called immediately before anotherSpy
- */
- calledImmediatelyBefore(anotherSpy: adone.shani.util.I.Spy): this;
- /**
- * Asserts that the spy has been called immediately after anotherSpy
- */
- calledImmediatelyAfter(anotherSpy: adone.shani.util.I.Spy): this;
- /**
- * Asserts that the spy has been called with context as this value
- */
- calledOn(context: object): this;
- /**
- * Asserts that the spy has been called with the given arguments
- */
- calledWith(...args: any[]): this;
- /**
- * Asserts that the spy has been called exactly with the given arguments
- */
- calledWithExactly(...args: any[]): this;
- /**
- * Asserts that the spy has been called with matching arguments
- */
- calledWithMatch(...args: any[]): this;
- /**
- * Asserts that the spy returned value
- */
- returned(value: any): this;
- /**
- * Asserts that the spy threw error
- */
- thrown(error: any): this;
- /**
- * Asserts that the spy threw error
- */
- threw(error: any): this;
- }
+ const config: I.Config;
+ const use: I.UseFunction;
+ const loadMockInterface: I.LoadInterfaceFunction;
+ const loadExpectInterface: I.LoadInterfaceFunction;
+ const loadAssertInterface: I.LoadInterfaceFunction;
+ const assert: I.AssertFunction;
+ const expect: I.ExpectFunction;
}
-
- class AssertionError extends adone.x.Exception {
- constructor(message?: string, props?: object, ssf?: object)
- }
-
- const config: I.Config;
- const use: I.UseFunction;
- const loadMockInterface: I.LoadInterfaceFunction;
- const loadExpectInterface: I.LoadInterfaceFunction;
- const loadAssertInterface: I.LoadInterfaceFunction;
- const assert: I.AssertFunction;
- const expect: I.ExpectFunction;
}
diff --git a/types/adone/glosses/collections.d.ts b/types/adone/glosses/collections.d.ts
new file mode 100644
index 0000000000..c21c13abb9
--- /dev/null
+++ b/types/adone/glosses/collections.d.ts
@@ -0,0 +1,1966 @@
+declare namespace adone {
+ namespace collection {
+ namespace I.LinkedList {
+ /**
+ * Represents the node of a linked list
+ */
+ interface Node {
+ /**
+ * The next node
+ */
+ next?: Node;
+
+ /**
+ * The previous node
+ */
+ prev?: Node;
+
+ /**
+ * The value this node contains
+ */
+ value: T;
+ }
+ }
+
+ /**
+ * Represents a linked list
+ */
+ class LinkedList {
+ /**
+ * The maximum length of the list
+ */
+ readonly maxLength: number;
+
+ /**
+ * Current length of the list
+ */
+ readonly length: number;
+
+ /**
+ * Whether the list is autoresizable
+ */
+ readonly autoresize: boolean;
+
+ /**
+ * @param maxLength Maximum length of the linked list
+ */
+ constructor(maxLength?: number);
+
+ /**
+ * Whether the list is full
+ */
+ readonly full: boolean;
+
+ /**
+ * Whether the list is empty
+ */
+ readonly empty: boolean;
+
+ /**
+ * Resizes the list
+ */
+ resize(newLength: number): this;
+
+ /**
+ * Adds a new node to the end
+ *
+ * @returns Added node
+ */
+ push(value: T): I.LinkedList.Node;
+
+ /**
+ * Removes the last node, returns undefined if the list is empty
+ */
+ pop(): T | undefined;
+
+ /**
+ * Removes the first node, returns undefined if the list is empty
+ */
+ shift(): T | undefined;
+
+ /**
+ * Inserts a new node at the beginning of the list
+ *
+ * @returns Added node
+ */
+ unshift(value: T): I.LinkedList.Node;
+
+ /**
+ * Moves the given node to the end of the list
+ */
+ pushNode(node: I.LinkedList.Node): void;
+
+ /**
+ * Moved the given node to the beginning of the list
+ */
+ unshiftNode(node: I.LinkedList.Node): void;
+
+ /**
+ * Removes the given node from the list
+ */
+ removeNode(node: I.LinkedList.Node): void;
+
+ /**
+ * Clears the list
+ *
+ * @param strong Whether to reset all the node's values
+ */
+ clear(strong?: boolean): void;
+
+ /**
+ * Convers the list to an array
+ */
+ toArray(): T[];
+
+ /**
+ * The first element of the list
+ */
+ readonly front: T;
+
+ /**
+ * The last element of the list
+ */
+ readonly back: T;
+
+ /**
+ * Returns an iterator over the list elements
+ */
+ [Symbol.iterator](): IterableIterator;
+
+ /**
+ * Returns the next node for the given node
+ */
+ nextNode(node: I.LinkedList.Node): I.LinkedList.Node;
+
+ /**
+ * Maps this linked list to a new one using the given function
+ */
+ map(fn: (value: T, index: number) => R): LinkedList;
+
+ /**
+ * Invokes the given callback for each value from the beginning to the end (much faster than for-of).
+ * If the given function returns false it stops iterating.
+ */
+ forEach(callback: (value: T, index: number) => void | boolean): void;
+
+ /**
+ * Default length of a new created linked list
+ */
+ static DEFAULT_LENGTH: number;
+ }
+
+ namespace I {
+ type Long = math.Long;
+
+ type Longable = math.I.Longable;
+
+ namespace ByteArray {
+ interface Varint32 {
+ value: number;
+ length: number;
+ }
+
+ interface Varint64 {
+ value: Long;
+ length: number;
+ }
+
+ interface String {
+ string: string;
+ length: number;
+ }
+
+ type Wrappable = string | ByteArray | Buffer | Uint8Array | ArrayBuffer;
+
+ type Metrics = "b" | "c";
+ }
+ }
+
+ /**
+ * Represents an array of bytes, enhanced Node.js Buffer
+ */
+ class ByteArray {
+ /**
+ * Constructs a new ByteArray
+ *
+ * @param capacity Initial capacity. Defaults to ByteArray.DEFAULT_CAPACITY(64)
+ * @param noAssert Whether to skip assertions of offsets and values. Defaults to ByteArray.DEFAULT_NOASSERT(false)
+ */
+ constructor(capacity?: number, noAssert?: boolean);
+
+ /**
+ * Reads a BitSet as an array of booleans.
+ *
+ * @param offset Offset to read from. Will use and increase offset by length if omitted.
+ */
+ readBitSet(offset?: number): boolean[];
+
+ /**
+ * Reads the specified number of bytes.
+ *
+ * @param length Number of bytes to read
+ * @param offset Offset to read from. Will use and increase offset by length if omitted.
+ */
+ read(length: number, offset?: number): ByteArray;
+
+ /**
+ * Reads an 8bit signed integer
+ *
+ * @param offset Offset to read from
+ */
+ readInt8(offset?: number): number;
+
+ /**
+ * Reads an 8bit unsigned integer
+ *
+ * @param offset Offset to read from
+ */
+ readUInt8(offset?: number): number;
+
+ /**
+ * Reads a 16bit signed le integer
+ *
+ * @param offset Offset to read from
+ */
+ readInt16LE(offset?: number): number;
+
+ /**
+ * Reads a 16bit unsigned le integer
+ *
+ * @param offset Offset to read from
+ */
+ readUInt16LE(offset?: number): number;
+
+ /**
+ * Reads a 16bit signed be integer
+ *
+ * @param offset Offset to read from
+ */
+ readInt16BE(offset?: number): number;
+
+ /**
+ * Reads a 16bit unsigned be integer
+ *
+ * @param offset Offset to read from
+ */
+ readUInt16BE(offset?: number): number;
+
+ /**
+ * Reads a 32bit signed le integer
+ *
+ * @param offset Offset to read from
+ */
+ readInt32LE(offset?: number): number;
+
+ /**
+ * Reads a 32bit unsigned le integer
+ *
+ * @param offset Offset to read from
+ */
+ readUInt32LE(offset?: number): number;
+
+ /**
+ * Reads a 32bit signed be integer
+ *
+ * @param offset Offset to read from
+ */
+ readInt32BE(offset?: number): number;
+
+ /**
+ * Reads a 32bit unsigned be integer
+ *
+ * @param offset Offset to read from
+ */
+ readUInt32BE(offset?: number): number;
+
+ /**
+ * Reads a 64bit signed le integer as math.Long
+ *
+ * @param offset Offset to read from
+ */
+ readInt64LE(offset?: number): math.Long;
+
+ /**
+ * Reads a 64bit unsigned le integer as math.Long
+ *
+ * @param offset Offset to read from
+ */
+ readUInt64LE(offset?: number): math.Long;
+
+ /**
+ * Reads a 64bit signed be integer as math.Long
+ *
+ * @param offset Offset to read from
+ */
+ readInt64BE(offset?: number): math.Long;
+
+ /**
+ * Reads a 64bit unsigned be integer as math.Long
+ *
+ * @param offset Offset to read from
+ */
+ readUInt64BE(offset?: number): math.Long;
+
+ /**
+ * Reads a 32bit le float
+ *
+ * @param offset Offset to read from
+ */
+ readFloatLE(offset?: number): number;
+
+ /**
+ * Reads a 32bit be float
+ *
+ * @param offset Offset to read from
+ */
+ readFloatBE(offset?: number): number;
+
+ /**
+ * Reads a 64bit le float
+ *
+ * @param offset Offset to read from
+ */
+ readDoubleLE(offset?: number): number;
+
+ /**
+ * Reads a 64bit be float
+ *
+ * @param offset Offset to read from
+ */
+ readDoubleBE(offset?: number): number;
+
+ /**
+ * Appends some data to this ByteArray.
+ * This will overwrite any contents behind the specified offset up to the appended data's length.
+ *
+ * @param source The source write from
+ * @param offset Offset to write to
+ * @param length length to read from the source
+ * @param encoding encoding to use for wrapping the source in bytearray
+ */
+ write(source: I.ByteArray.Wrappable, offset?: number, length?: number, encoding?: string): this;
+
+ /**
+ * Writes the array as a bitset.
+ * @param value Array of booleans to write
+ */
+ writeBitSet(value: number[]): this;
+
+ /**
+ * Writes the array as a bitset.
+ * @param value Array of booleans to write
+ * @param offset Offset to write to
+ */
+ writeBitSet(value: number[], offset: number): number;
+
+ /**
+ * Writes an 8bit signed integer
+ *
+ * @param offset Offset to write to
+ */
+ writeInt8(value: number, offset?: number): this;
+
+ /**
+ * Writes an 8bit unsigned integer
+ *
+ * @param offset Offset to write to
+ */
+ writeUInt8(value: number, offset?: number): this;
+
+ /**
+ * Writes a 16bit signed le integer
+ *
+ * @param offset Offset to write to
+ */
+ writeInt16LE(value: number, offset?: number): this;
+
+ /**
+ * Writes a 16bit signed be integer
+ *
+ * @param offset Offset to write to
+ */
+ writeInt16BE(value: number, offset?: number): this;
+
+ /**
+ * Writes a 16bit unsigned le integer
+ *
+ * @param offset Offset to write to
+ */
+ writeUInt16LE(value: number, offset?: number): this;
+
+ /**
+ * Writes a 16bit unsigned be integer
+ *
+ * @param offset Offset to write to
+ */
+ writeUInt16BE(value: number, offset?: number): this;
+
+ /**
+ * Writes a 32bit signed le integer
+ *
+ * @param offset Offset to write to
+ */
+ writeInt32LE(value: number, offset?: number): this;
+
+ /**
+ * Writes a 32bit signed be integer
+ *
+ * @param offset Offset to write to
+ */
+ writeInt32BE(value: number, offset?: number): this;
+
+ /**
+ * Writes a 32bit unsigned le integer
+ *
+ * @param offset Offset to write to
+ */
+ writeUInt32LE(value: number, offset?: number): this;
+
+ /**
+ * Writes a 32bit unsigned be integer
+ *
+ * @param offset Offset to write to
+ */
+ writeUInt32BE(value: number, offset?: number): this;
+
+ /**
+ * Writes a 64bit signed le long integer
+ *
+ * @param offset Offset to write to
+ */
+ writeInt64LE(value: math.Long | string | number, offset?: number): this;
+
+ /**
+ * Writes a 64bit signed be long integer
+ *
+ * @param offset Offset to write to
+ */
+ writeInt64BE(value: math.Long | string | number, offset?: number): this;
+
+ /**
+ * Writes a 64bit unsigned le long integer
+ *
+ * @param offset Offset to write to
+ */
+ writeUInt64LE(value: math.Long | string | number, offset?: number): this;
+
+ /**
+ * Writes a 64bit unsigned be long integer
+ *
+ * @param offset Offset to write to
+ */
+ writeUInt64BE(value: math.Long | string | number, offset?: number): this;
+
+ /**
+ * Writes a 32bit le float
+ *
+ * @param offset Offset to write to
+ * @returns {this}
+ */
+ writeFloatLE(value: number, offset?: number): this;
+
+ /**
+ * Writes a 32bit be float
+ *
+ * @param offset Offset to write to
+ */
+ writeFloatBE(value: number, offset?: number): this;
+
+ /**
+ * Writes a 64bit le float
+ *
+ * @param offset Offset to write to
+ */
+ writeDoubleLE(value: number, offset?: number): this;
+
+ /**
+ * Writes a 64bit be float
+ *
+ * @param offset Offset to write to
+ */
+ writeDoubleBE(value: number, offset?: number): this;
+
+ /**
+ * Writes a 32bit base 128 variable-length integer
+ */
+ writeVarint32(value: number): this;
+
+ /**
+ * Writes a 32bit base 128 variable-length integer
+ *
+ * @param offset Offset to write to
+ */
+ writeVarint32(value: number, offset: number): number;
+
+ /**
+ * Writes a zig-zag encoded 32bit base 128 variable-length integer
+ */
+ writeVarint32ZigZag(value: number): this;
+
+ /**
+ * Writes a zig-zag encoded 32bit base 128 variable-length integer
+ *
+ * @param offset Offset to write to
+ */
+ writeVarint32ZigZag(value: number, offset: number): number;
+
+ /**
+ * Reads a 32bit base 128 variable-length integer
+ */
+ readVarint32(): number;
+
+ /**
+ * Reads a 32bit base 128 variable-length integer
+ *
+ * @param offset Offset to read from
+ */
+ readVarint32(offset: number): I.ByteArray.Varint32;
+
+ /**
+ * Reads a zig-zag encoded 32bit base 128 variable-length integer
+ */
+ readVarint32ZigZag(): number;
+
+ /**
+ * Reads a zig-zag encoded 32bit base 128 variable-length integer
+ *
+ * @param offset Offset to read from
+ */
+ readVarint32ZigZag(offset: number): I.ByteArray.Varint32;
+
+ /**
+ * Writes a 64bit base 128 variable-length integer
+ */
+ writeVarint64(value: math.Long | string | number): this;
+
+ /**
+ * Writes a 64bit base 128 variable-length integer
+ *
+ * @param offset Offset to write to
+ */
+ writeVarint64(value: math.Long | string | number, offset: number): number;
+
+ /**
+ * Writes a zig-zag encoded 64bit base 128 variable-length integer
+ */
+ writeVarint64ZigZag(value: math.Long | string | number): this;
+
+ /**
+ * Writes a zig-zag encoded 64bit base 128 variable-length integer
+ *
+ * @param offset Offset to write to
+ */
+ writeVarint64ZigZag(value: math.Long | string | number, offset: number): number;
+
+ /**
+ * Reads a 64bit base 128 variable-length integer
+ */
+ readVarint64(): I.Long;
+
+ /**
+ * Reads a 64bit base 128 variable-length integer
+ *
+ * @param offset Offset to read from
+ */
+ readVarint64(offset: number): I.ByteArray.Varint64;
+
+ /**
+ * Reads a zig-zag encoded 64bit base 128 variable-length integer
+ */
+ readVarint64ZigZag(): math.Long;
+
+ /**
+ * Reads a zig-zag encoded 64bit base 128 variable-length integer
+ *
+ * @param offset Offset to read from
+ */
+ readVarint64ZigZag(offset: number): I.ByteArray.Varint64;
+
+ /**
+ * Writes a NULL-terminated UTF8 encoded string.
+ * For this to work the specified string must not contain any NULL characters itself
+ */
+ writeCString(str: string): this;
+
+ /**
+ * Writes a NULL-terminated UTF8 encoded string.
+ * For this to work the specified string must not contain any NULL characters itself
+ *
+ * @param offset Offset to write to
+ */
+ writeCString(str: string, offset: number): number;
+
+ /**
+ * Reads a NULL-terminated UTF8 encoded string.
+ * For this to work the string read must not contain any NULL characters itself
+ */
+ readCString(): string;
+
+ /**
+ * Reads a NULL-terminated UTF8 encoded string.
+ * For this to work the string read must not contain any NULL characters itself
+ *
+ * @param offset Offset to read from
+ */
+ readCString(offset: number): I.ByteArray.String;
+
+ /**
+ * Writes an UTF8 encoded string
+ */
+ writeString(str: string): this;
+
+ /**
+ * Writes an UTF8 encoded string
+ *
+ * @param offset Offset to write to
+ */
+ writeString(str: string, offset: number): number;
+
+ /**
+ * Reads an UTF8 encoded string
+ *
+ * @param length Number of characters or bytes to read
+ * @param metrics Metrics specifying what n is meant to count. Defaults to ByteArray.METRICS_CHARS("c")
+ */
+ readString(length: number, metrics?: I.ByteArray.Metrics): string;
+
+ /**
+ * Reads an UTF8 encoded string
+ *
+ * @param length Number of characters or bytes to read
+ * @param metrics Metrics specifying what n is meant to count. Defaults to ByteArray.METRICS_CHARS("c")
+ * @param offset Offset to read from
+ */
+ readString(length: number, metrics: I.ByteArray.Metrics, offset: number): I.ByteArray.String;
+
+ /**
+ * Reads an UTF8 encoded string
+ *
+ * @param length Number of characters or bytes to read
+ * @param offset Offset to read from
+ */
+ readString(length: number, offset: number): I.ByteArray.String;
+
+ /**
+ * Writes a length as varint32 prefixed UTF8 encoded string
+ */
+ writeVString(str: string): this;
+
+ /**
+ * Writes a length as varint32 prefixed UTF8 encoded string
+ *
+ * @param offset Offset to read from
+ */
+ writeVString(str: string, offset: number): number;
+
+ /**
+ * Reads a length as varint32 prefixed UTF8 encoded string
+ */
+ readVString(): string;
+
+ /**
+ * Reads a length as varint32 prefixed UTF8 encoded string
+ *
+ * @param offset Offset to read from
+ */
+ readVString(offset: number): I.ByteArray.String;
+
+ /**
+ * Appends this ByteArray's contents to another ByteArray.
+ * This will overwrite any contents behind the specified offset up to the length of this ByteArray's data
+ *
+ * @param offset Offset to append to
+ */
+ appendTo(target: ByteArray, offset?: number): this;
+
+ /**
+ * Enables or disables assertions of argument types and offsets.
+ * Assertions are enabled by default but you can opt to disable them if your code already makes sure that everything is valid
+ */
+ assert(assert?: boolean): this;
+
+ /**
+ * Gets the capacity of this ByteArray's backing buffer
+ */
+ capacity(): number;
+
+ /**
+ * Clears this ByteArray's offsets by setting offset to 0 and limit to the backing buffer's capacity
+ */
+ clear(): this;
+
+ /**
+ * Creates a cloned instance of this ByteArray,
+ * preset with this ByteArray's values for offset, markedOffset and limit
+ *
+ * @param copy Whether to copy the backing buffer or to return another view on the same, false by default
+ */
+ clone(copy?: boolean): ByteArray;
+
+ /**
+ * Compacts this ByteArray to be backed by a buffer of its contents' length.
+ * Will set offset = 0 and limit = capacity and adapt markedOffset to the same relative position if set
+ *
+ * @param begin Offset to start at, buffer offset by default
+ * @param end Offset to end at, buffer limit by default
+ */
+ compact(begin?: number, end?: number): this;
+
+ /**
+ * Creates a copy of this ByteArray's contents.
+ *
+ * @param begin Begin offset, buffer offset by default
+ * @param end End offset, buffer limit by default
+ */
+ copy(begin?: number, end?: number): ByteArray;
+
+ /**
+ * Copies this ByteArray's contents to another ByteArray.
+ *
+ * @param targetOffset Offset to copy to. Will use and increase the target's offset by the number of bytes copied if omitted
+ * @param sourceOffset Offset to start copying from. Will use and increase offset by the number of bytes copied if omitted
+ * @param sourceLimit Offset to end copying from, defaults to the buffer limit
+ */
+ copyTo(target: ByteArray, targetOffset?: number, souceOffset?: number, sourceLimit?: number): this | ByteArray;
+
+ /**
+ * Makes sure that this ByteArray is backed by a ByteArray#buffer of at least the specified capacity.
+ * If the current capacity is exceeded, it will be doubled.
+ * If double the current capacity is less than the required capacity, the required capacity will be used instead
+ */
+ ensureCapacity(capacity: number): this;
+
+ /**
+ * Overwrites this ByteArray's contents with the specified value.
+ *
+ * @param value Byte value to fill with. If given as a string, the first character is used
+ * @param begin Begin offset. Will use and increase offset by the number of bytes written if omitted. defaults to offset
+ * @param end End offset, defaults to limit.
+ */
+ fill(value: string | number, begin?: number, end?: number): this;
+
+ /**
+ * Makes this ByteArray ready for a new sequence of write or relative read operations.
+ * Sets limit = offset and offset = 0.
+ * Make sure always to flip a ByteArray when all relative read or write operations are complete
+ */
+ flip(): this;
+
+ /**
+ * Marks an offset on this ByteArray to be used later
+ *
+ * @param offset Offset to mark. Defaults to offset.
+ */
+ mark(offset?: number): this;
+
+ /**
+ * Prepends some data to this ByteArray.
+ * This will overwrite any contents before the specified offset up to the prepended data's length.
+ * If there is not enough space available before the specified offset,
+ * the backing buffer will be resized and its contents moved accordingly
+ *
+ * @param source Data to prepend
+ * @param offset Offset to prepend at. Will use and decrease offset by the number of bytes prepended if omitted.
+ */
+ prepend(source: I.ByteArray.Wrappable, offset: number): this;
+
+ /**
+ * Prepends some data to this ByteArray.
+ * This will overwrite any contents before the specified offset up to the prepended data's length.
+ * If there is not enough space available before the specified offset,
+ * the backing buffer will be resized and its contents moved accordingly
+ *
+ * @param source Data to prepend
+ * @param encoding Encoding if data is a string
+ * @param offset Offset to prepend at. Will use and decrease offset by the number of bytes prepended if omitted.
+ */
+ prepend(source: I.ByteArray.Wrappable, encoding?: string, offset?: number): this;
+
+ /**
+ * Prepends this ByteArray to another ByteArray.
+ * This will overwrite any contents before the specified offset up to the prepended data's length.
+ * If there is not enough space available before the specified offset,
+ * the backing buffer will be resized and its contents moved accordingly
+ *
+ * @param offset Offset to prepend at
+ */
+ prependTo(target: ByteArray, offset?: number): this;
+
+ /**
+ * Gets the number of remaining readable bytes
+ */
+ remaining(): number;
+
+ /**
+ * Resets this ByteArray's offset.
+ * If an offset has been marked through mark before, offset will be set to markedOffset, which will then be discarded.
+ * If no offset has been marked, sets offset = 0
+ */
+ reset(): this;
+
+ /**
+ * Resizes this ByteArray to be backed by a buffer of at least the given capacity.
+ * Will do nothing if already that large or larger.
+ *
+ * @param {number} capacity Capacity required
+ * @returns {this}
+ */
+ resize(capacity: number): this;
+
+ /**
+ * Reverses this ByteArray's contents.
+ *
+ * @param begin Offset to start at, defaults to offset
+ * @param end Offset to end at, defaults to limit
+ */
+ reverse(begin?: number, end?: number): this;
+
+ /**
+ * Skips the next length bytes. This will just advance
+ */
+ skip(length: number): this;
+
+ /**
+ * Slices this ByteArray by creating a cloned instance with offset = begin and limit = end
+ *
+ * @param begin Begin offset, defaults to offset
+ * @param end End offset, defaults to limit
+ */
+ slice(begin?: number, end?: number): ByteArray;
+
+ /**
+ * Returns a copy of the backing buffer that contains this ByteArray's contents.
+ *
+ * @param forceCopy If true returns a copy, otherwise returns a view referencing the same memory if possible, false by default
+ * @param begin Begin offset, offset by default
+ * @param end End offset, limit by default
+ */
+ toBuffer(forceCopy?: boolean, begin?: number, end?: number): Buffer;
+
+ /**
+ * Returns a raw buffer compacted to contain this ByteArray's contents
+ */
+ toArrayBuffer(): ArrayBuffer;
+
+ /**
+ * Converts the ByteArray's contents to a string
+ *
+ * @param encoding Output encoding
+ * @param begin Begin offset, offset by default
+ * @param end End offset, limit by default
+ */
+ toString(encoding?: string, begin?: number, end?: number): string;
+
+ /**
+ * Encodes this ByteArray's contents to a base64 encoded string
+ *
+ * @param begin Begin offset, offset by default
+ * @param end End offset, limit by default
+ */
+ toBase64(begin?: number, end?: number): string;
+
+ /**
+ * Encodes this ByteArray to a binary encoded string, that is using only characters 0x00-0xFF as bytes
+ *
+ * @param begin Begin offset, offset by default
+ * @param end End offset, limit by default
+ */
+ toBinary(begin?: number, end?: number): string;
+
+ /**
+ * Encodes this ByteArray to a hex encoded string with marked offsets
+ *
+ * @param columns If true returns two columns hex + ascii, defaults to false
+ */
+ toDebug(columns?: boolean): string;
+
+ /**
+ * Encodes this ByteArray's contents to a hex encoded string
+ *
+ * @param begin Begin offset, offset by default
+ * @param end End offset, limit by default
+ */
+ toHex(begin?: number, end?: number): string;
+
+ /**
+ * Encodes this ByteArray's contents to an UTF8 encoded string
+ *
+ * @param begin Begin offset, offset by default
+ * @param end End offset, limit by default
+ */
+ toUTF8(begin?: number, end?: number): string;
+
+ static accessor(): typeof Buffer;
+
+ /**
+ * Allocates a new ByteArray backed by a buffer of the specified capacity.
+ *
+ * @param capacity Initial capacity. Defaults to ByteArray.DEFAULT_CAPACITY(64)
+ * @param noAssert Whether to skip assertions of offsets and values. Defaults to ByteArray.DEFAULT_NOASSERT(false)
+ */
+ static allocate(capacity?: number, noAssert?: boolean): ByteArray;
+
+ /**
+ * Concatenates multiple ByteArrays into one
+ *
+ * @param encoding Encoding for strings
+ * @param noAssert Whether to skip assertions of offsets and values. Defaults to ByteArray.DEFAULT_NOASSERT(false)
+ */
+ static concat(buffers: I.ByteArray.Wrappable[], encoding?: string, noAssert?: boolean): ByteArray;
+
+ static type(): typeof Buffer;
+
+ /**
+ * Wraps a buffer or a string.
+ * Sets the allocated ByteArray's offset to 0 and its limit to the length of the wrapped data
+ *
+ * @param encoding Encoding for strings
+ * @param noAssert Whether to skip assertions of offsets and values. Defaults to ByteArray.DEFAULT_NOASSERT(false)
+ */
+ static wrap(buffer: I.ByteArray.Wrappable, encoding?: string, noAssert?: boolean): ByteArray;
+
+ /**
+ * Calculates the actual number of bytes required to store a 32bit base 128 variable-length integer
+ */
+ static calculateVarint32(value: number): number;
+
+ /**
+ * Zigzag encodes a signed 32bit integer so that it can be effectively used with varint encoding
+ */
+ static zigZagEncode32(n: number): number;
+
+ /**
+ * Decodes a zigzag encoded signed 32bit integer
+ */
+ static zigZagDecode32(n: number): number;
+
+ /**
+ * Calculates the actual number of bytes required to store a 64bit base 128 variable-length integer
+ */
+ static calculateVarint64(value: number | string): number;
+
+ /**
+ * Zigzag encodes a signed 64bit integer so that it can be effectively used with varint encoding
+ */
+ static zigZagEncode64(value: number | string | I.Long): I.Long;
+
+ /**
+ * Decodes a zigzag encoded signed 64bit integer.
+ */
+ static zigZagDecode64(value: number | string | I.Long): I.Long;
+
+ /**
+ * Calculates the number of UTF8 characters of a string.
+ * JavaScript itself uses UTF-16,
+ * so that a string's length property does not reflect its actual UTF8 size if it contains code points larger than 0xFFFF
+ */
+ static calculateUTF8Chars(str: string): number;
+
+ /**
+ * Calculates the number of UTF8 bytes of a string.
+ */
+ static calculateString(str: string): number;
+
+ /**
+ * Decodes a base64 encoded string to a ByteArray
+ */
+ static fromBase64(str: string): ByteArray;
+
+ /**
+ * Encodes a binary string to base64 like window.btoa does
+ */
+ static btoa(str: string): string;
+
+ /**
+ * Decodes a base64 encoded string to binary like window.atob does
+ */
+ static atob(b64: string): string;
+
+ /**
+ * Decodes a binary encoded string, that is using only characters 0x00-0xFF as bytes, to a ByteArray
+ */
+ static fromBinary(str: string): ByteArray;
+
+ /**
+ * Decodes a hex encoded string with marked offsets to a ByteArray
+ */
+ static fromDebug(str: string, noAssert?: boolean): ByteArray;
+
+ /**
+ * Decodes a hex encoded string to a ByteArray
+ */
+ static fromHex(str: string, noAssert?: boolean): ByteArray;
+
+ /**
+ * Decodes an UTF8 encoded string to a ByteArray
+ */
+ static fromUTF8(str: string, noAssert?: boolean): ByteArray;
+
+ /**
+ * Default initial capacity
+ */
+ static DEFAULT_CAPACITY: number;
+
+ /**
+ * Default no assertions flag
+ */
+ static DEFAULT_NOASSERT: boolean;
+
+ /**
+ * Maximum number of bytes required to store a 32bit base 128 variable-length integer
+ */
+ static MAX_VARINT32_BYTES: number;
+
+ /**
+ * Maximum number of bytes required to store a 64bit base 128 variable-length integer
+ */
+ static MAX_VARINT64_BYTES: number;
+
+ /**
+ * Metrics representing number of UTF8 characters. Evaluates to `c`.
+ */
+ static METRICS_CHARS: string;
+
+ /**
+ * Metrics representing number of bytes. Evaluates to `b`.
+ */
+ static METRICS_BYTES: string;
+ }
+
+ /**
+ * Represents a queue
+ */
+ class Queue {
+ /**
+ * Whether the queue is full
+ */
+ readonly full: boolean;
+
+ /**
+ * The length of the queue
+ */
+ readonly length: number;
+
+ /**
+ * Whether the queue is empty
+ */
+ readonly empty: boolean;
+
+ /**
+ * Inserts a new element at the end
+ */
+ push(x: S): this;
+
+ /**
+ * Removes and returns an element from the beginning
+ */
+ pop(): T | undefined;
+ }
+
+ /**
+ * Represents an asynchronous queue, each pop is a promise
+ * that is resolved with an existing element or an element that will be pushed in the future
+ */
+ class AsyncQueue extends Queue> {
+ /**
+ * Returns a promise that will be resolved with an existing element or an element that will be pushed in the future
+ */
+ pop(): Promise;
+ }
+
+ namespace I.PriorityQueue {
+ interface ConstructorOptions {
+ /**
+ * Function that compares objects.
+ *
+ * Must return a positive value if a > b, a negative if a < b, and zero for equal objects
+ */
+ compare?(a: T, b: T): number;
+
+ /**
+ * Function that evaluates the priority value by the given objects,
+ * if the returned value > 0, then the first argument has higher priority,
+ * = 0 same priority, < 0 lower priority.
+ * By default the top element is an element that has the highest priority,
+ * the default priority function is equal to the compare function
+ */
+ priority?(a: T, b: T): number;
+ }
+ }
+
+ /**
+ * Represents a priority queue
+ */
+ class PriorityQueue {
+ /**
+ * Whether the queue is empty
+ */
+ readonly empty: boolean;
+
+ /**
+ * The length of the queue
+ */
+ readonly length: number;
+
+ constructor(options?: I.PriorityQueue.ConstructorOptions);
+
+ /**
+ * Clones the queue
+ */
+ clone(): PriorityQueue;
+
+ /**
+ * Inserts a new element
+ */
+ push(x: T): this;
+
+ /**
+ * Removes the top element (that has the highest priority)
+ */
+ pop(): T | undefined;
+
+ /**
+ * Deletes the given element from the queue
+ */
+ delete(x: T): this;
+
+ /**
+ * Replaces the top element (pop + push)
+ */
+ replace(x: T): T;
+
+ /**
+ * Faster push + pop
+ */
+ pushpop(x: T): T;
+
+ /**
+ * Converts the queue to an array, it works with a clone of the queue, so the original queue is untouched
+ */
+ toArray(): T[];
+
+ /**
+ * Creates a queue object from the given iterable
+ */
+ static from(iterable: Iterable, options?: I.PriorityQueue.ConstructorOptions): PriorityQueue;
+ }
+
+ /**
+ * Represents a faster LRU cache but with less functionality
+ */
+ class FastLRU {
+ /**
+ * @param size Cache size, unlimited by default
+ */
+ constructor(size?: number, options?: {
+ /**
+ * Function that is called when a value is deleted
+ */
+ dispose?(key: K, value: V): void
+ });
+
+ /**
+ * The actual size of the cache
+ */
+ readonly size: number;
+
+ /**
+ * Gets the value by the given key
+ */
+ get(key: K): V | undefined;
+
+ /**
+ * Sets a new value for the given key
+ */
+ set(key: K, value: V): void;
+
+ /**
+ * Deletes the given key from the cache
+ */
+ delete(key: K): boolean;
+
+ /**
+ * Checks whether the cache has an element with the given key
+ */
+ has(key: K): boolean;
+
+ /**
+ * Returns the keys iterator
+ */
+ keys(): IterableIterator;
+
+ /**
+ * Returns the values iterator
+ */
+ values(): IterableIterator;
+
+ /**
+ * Returns the entries iterator
+ */
+ entries(): IterableIterator<[K, V]>;
+
+ /**
+ * Clears the cache
+ */
+ clear(): void;
+ }
+
+ /**
+ * Represents a stack
+ */
+ class Stack {
+ /**
+ * Whether the stack is empty
+ */
+ readonly empty: boolean;
+
+ /**
+ * The top element of the stack
+ */
+ readonly top: T;
+
+ /**
+ * Inserts a new element
+ */
+ push(x: T): this;
+
+ /**
+ * Removes the top element
+ */
+ pop(): T | undefined;
+
+ /**
+ * Returns an iterator over the values
+ */
+ [Symbol.iterator](): IterableIterator;
+
+ /**
+ * Creates a stack and pushed all the values from the given iterable object
+ */
+ static from(iterable: Iterable): Stack;
+ }
+
+ namespace I.BinarySearchTree {
+ interface ConstructorOptions {
+ /**
+ * The parent tree
+ */
+ parent?: Tree;
+
+ /**
+ * Value to keep in this node
+ */
+ value?: V;
+
+ /**
+ * WHether the values must be unique, false by default.
+ * If false you can store many values for same keys, otherwise only one
+ */
+ unique?: boolean;
+
+ /**
+ * Custom keys comparator, by default if a > b => -1, a < b -1, a === b => 0
+ */
+ compareKeys?(a: K, b: K): number;
+
+ /**
+ * Function that defines whether 2 values are the same, by default a === b
+ */
+ checkValueEquality?(a: V, b: V): boolean;
+ }
+
+ interface Query {
+ $lt?: K;
+ $lte?: K;
+ $gt?: K;
+ $gte?: K;
+ }
+ }
+
+ /**
+ * Represents a binary search tree
+ */
+ class BinarySearchTree {
+ constructor(options?: I.BinarySearchTree.ConstructorOptions>);
+
+ /**
+ * Returns the max descendant tree
+ */
+ getMaxKeyDescendant(): BinarySearchTree;
+
+ /**
+ * Returns the maximum key
+ */
+ getMaxKey(): K;
+
+ /**
+ * Returns the min descendant tree
+ */
+ getMinKeyDescendant(): BinarySearchTree;
+
+ /**
+ * Returns the minumum key
+ */
+ getMinKey(): K;
+
+ /**
+ * Traverses the tree and calls the given function for each node
+ */
+ checkAllNodesFullfillCondition(test: (key: K, value: V) => void): void;
+
+ /**
+ * Checks whether the tree is a binary search tree
+ */
+ checkIsBST(): void;
+
+ /**
+ * Returns the of keys in the tree
+ */
+ getNumberOfKeys(): number;
+
+ /**
+ * Inserts a new key/value
+ */
+ insert(key: K, value: V): void;
+
+ /**
+ * Searches the given key in the tree
+ */
+ search(key: K): V[];
+
+ /**
+ * Returns all the values from the given key bounds
+ */
+ betweenBounds(query: I.BinarySearchTree.Query): V[];
+
+ /**
+ * Deletes the given key/value from the tree
+ */
+ delete(key: K, value?: V): void;
+
+ /**
+ * Executed the given callback for each node from left to right
+ */
+ executeOnEveryNode(fn: (tree: BinarySearchTree) => void): void;
+
+ /**
+ * Prints the tree
+ */
+ prettyPrint(printData?: boolean, spacing?: string): void;
+ }
+
+ /**
+ * Represents an AVL tree, a self-balancing binary search tree
+ */
+ class AVLTree {
+ constructor(options?: I.BinarySearchTree.ConstructorOptions>);
+
+ /**
+ * Checks whether the tree is an avl tree
+ */
+ checkIsAVLT(): void;
+
+ /**
+ * Inserts a new key/value
+ */
+ insert(key: K, value: V): void;
+
+ /**
+ * Deletes the given key/value from the tree
+ */
+ delete(key: K, value?: V): void;
+
+ /**
+ * Returns the of keys in the tree
+ */
+ getNumberOFKeys(): number;
+
+ /**
+ * Searches the given key in the tree
+ */
+ search(key: K): V[];
+
+ /**
+ * Returns all the values from the given key bounds
+ */
+ betweenBounds(query: I.BinarySearchTree.Query): V[];
+
+ /**
+ * Executed the given callback for each node from left to right
+ */
+ executeOnEveryNode(fn: (tree: AVLTree) => void): void;
+
+ /**
+ * Prints the tree
+ */
+ prettyPrint(printDate?: boolean, spacing?: string): void;
+ }
+
+ namespace I.RedBlackTree {
+ interface Node {
+ /**
+ * The key associated to the node
+ */
+ key: K;
+
+ /**
+ * The value associated to the node
+ */
+ value: V;
+
+ /**
+ * The left subtree of the node
+ */
+ left?: Node;
+
+ /**
+ * The right subtree of the node
+ */
+ right?: Node;
+ }
+
+ interface Iterator {
+ /**
+ * Checks if the iterator is valid
+ */
+ readonly valid: boolean;
+
+ /**
+ * The value of the node at the iterator's current position, null if invalid
+ */
+ readonly node: Node | null;
+
+ /**
+ * The key of the item referenced by the iterator, undefined if invalid
+ */
+ readonly key?: K;
+
+ /**
+ * The value of the item referenced by the iterator, undefined if invalid
+ */
+ readonly value?: V;
+
+ /**
+ * Returns the position of this iterator in the sequence
+ */
+ readonly index: number;
+
+ /**
+ * If true, then the iterator is not at the end of the sequence
+ */
+ readonly hasNext: boolean;
+
+ /**
+ * If true, then the iterator is not at the beginning of the sequence
+ */
+ readonly hasPrev: boolean;
+
+ /**
+ * The tree associated to the iterator
+ */
+ tree: RedBlackTree;
+
+ /**
+ * Makes a copy of the iterator
+ */
+ clone(): Iterator;
+
+ /**
+ * Removes the item at the position of the iterator and returns a new rb-tree
+ */
+ remove(): RedBlackTree;
+
+ /**
+ * Advances the iterator to the next position
+ */
+ next(): void;
+
+ /**
+ * Updates the value of the node in the tree at this iterator and returns a new rb-tree
+ */
+ update(value: V): RedBlackTree;
+
+ /**
+ * Moves the iterator backward one element
+ */
+ prev(): void;
+ }
+ }
+
+ /**
+ * Represents a fully persistent red-black tree
+ */
+ class RedBlackTree {
+ /**
+ * The root node of the tree
+ */
+ root: I.RedBlackTree.Node;
+
+ constructor(compare?: (a: K, b: K) => number, root?: RedBlackTree);
+
+ /**
+ * A sorted array of all the keys in the tree
+ */
+ readonly keys: K[];
+
+ /**
+ * An array of all the values in the tree
+ */
+ readonly values: V[];
+
+ /**
+ * The number of items in the tree
+ */
+ readonly length: number;
+
+ /**
+ * An iterator pointing to the first element in the tree
+ */
+ readonly begin: I.RedBlackTree.Iterator;
+
+ /**
+ * An iterator pointing to the last element in the tree
+ */
+ readonly end: I.RedBlackTree.Iterator;
+
+ /**
+ * Creates a new tree with the new pair inserted
+ */
+ insert(key: K, value: V): RedBlackTree;
+
+ /**
+ * Walks a visitor function over the nodes of the tree in order
+ *
+ * @param visit A callback that gets executed on each node.
+ * If a truthy value is returned from the visitor, then iteration is stopped.
+ * @param lo An optional start of the range to visit (inclusive)
+ * @param hi An optional end of the range to visit (non-inclusive)
+ */
+ forEach(visit: (key: K, value: V) => T, lo?: K, hi?: K): T;
+
+ /**
+ * Finds an iterator starting at the given element
+ */
+ at(idx: number): I.RedBlackTree.Iterator;
+
+ /**
+ * Finds the first item in the tree whose key is >= key
+ */
+ ge(key: K): I.RedBlackTree.Iterator;
+
+ /**
+ * Finds the first item in the tree whose key is > key
+ */
+ gt(key: K): I.RedBlackTree.Iterator;
+
+ /**
+ * Finds the first item in the tree whose key is < key
+ */
+ lt(key: K): I.RedBlackTree.Iterator;
+
+ /**
+ * Finds the first item in the tree whose key is <= key
+ */
+ le(key: K): I.RedBlackTree.Iterator;
+
+ /**
+ * Returns an iterator pointing to the first item in the tree with key, otherwise null
+ */
+ find(key: K): I.RedBlackTree.Iterator | null;
+
+ /**
+ * Removes the first item with key in the tree
+ */
+ remove(key: K): RedBlackTree;
+
+ /**
+ * Retrieves the value associated to the given key
+ */
+ get(key: K): V | undefined;
+ }
+
+ /**
+ * Respresetns a data structure which is a combination of an array and a set.
+ * Adding a new member is O(1), testing for membership is O(1),
+ * and finding the index of an element is O(1).
+ */
+ class ArraySet {
+ /**
+ * The number of unique items in this ArraySet.
+ * If duplicates have been added, than those do not count towards the size.
+ */
+ readonly length: number;
+
+ /**
+ * Adds the given value to this set.
+ *
+ * @param allowDuplicates Whether to allow duplicates in the set, false by default
+ */
+ add(value: T, allowDuplicates?: boolean): this;
+
+ /**
+ * Checks whether the given value is a member of the set
+ */
+ has(value: T): boolean;
+
+ /**
+ * Returns the index of the given element.
+ * If the value is not present it will return -1
+ */
+ indexOf(value: T): number;
+
+ /**
+ * Converts the set to an array
+ */
+ toArray(): T[];
+
+ /**
+ * Creates an ArraySet from the given iterable object
+ *
+ * @param allowDuplicates Whether to allow duplicates in the set, false by default
+ */
+ static from(iterable: Iterable, allowDuplicates?: boolean): ArraySet;
+ }
+
+ namespace I.BufferList {
+ type Appendable = Buffer | BufferList | string | number | Array;
+ }
+
+ /**
+ * Represents a Node.js Buffer list collector, reader and streamer with callback/promise interface support
+ */
+ class BufferList extends std.stream.Duplex implements PromiseLike {
+ /**
+ * Creates a new buffer list
+ */
+ constructor();
+
+ /**
+ * Creates a new buffer list and initiates with the given value
+ */
+ constructor(buffer: I.BufferList.Appendable);
+
+ /**
+ * Creates a new buffer list and subscribes the given callback on the end/error event
+ */
+ constructor(callback: (err: any, data: Buffer) => void);
+
+ /**
+ * Adds an additional buffer or BufferList to the internal list
+ */
+ append(buf: I.BufferList.Appendable): this;
+
+ /**
+ * Ends the stream
+ */
+ end(chunk?: Buffer): void;
+
+ /**
+ * Returns the byte at the specified index
+ */
+ get(idx: number): number;
+
+ /**
+ * Returns a new Buffer object containing the bytes within the range specified.
+ */
+ slice(start?: number, end?: number): Buffer;
+
+ /**
+ * Copies the content of the list in the dest buffer
+ * starting from destStart and containing the bytes within the range specified with srcStart to srcEnd
+ *
+ * @param dstStart writes from this position
+ * @param srcStart reads bytes from this position
+ * @param srcEnd read bytes to this position
+ */
+ copy(dst: T, dstStart?: number, srcStart?: number, srcEnd?: number): T;
+
+ /**
+ * Returns a new BufferList object containing the bytes within the range specified.
+ * No copies will be performed. All buffers in the result share memory with the original list.
+ *
+ * @param {number} start slice from
+ * @param {number} end slice to
+ */
+ shallowSlice(start?: number, end?: number): BufferList;
+
+ /**
+ * Return a string representation of the buffer
+ */
+ toString(encoding?: fs.I.Encoding, start?: number, end?: number): string;
+
+ /**
+ * Shifts bytes off the start of the list
+ */
+ consume(bytes: number): this;
+
+ /**
+ * Performs a shallow-copy of the list.
+ */
+ duplicate(): BufferList;
+
+ /**
+ * Destroys the stream
+ */
+ destroy(): void;
+
+ then(
+ onfulfilled?: ((value: Buffer) => T1 | PromiseLike) | undefined | null,
+ onrejected?: ((reason: any) => T2 | PromiseLike) | undefined | null
+ ): PromiseLike;
+
+ catch(onrejected?: ((reason: any) => T | PromiseLike) | undefined | null): PromiseLike;
+ }
+
+ /**
+ * Represents a Map that has a default values factory object or function.
+ * Each get of non-existent key goes through the factory
+ */
+ class DefaultMap extends Map {
+ constructor(factory?: ((key: K) => V) | { [key: string]: V }, iterable?: Iterable<[K, V]>);
+ }
+
+ namespace I.LRU {
+ type LengthCalculator = (value: V, key: K) => number;
+ interface ConstructorOptions {
+ /**
+ * The maximum size of the cache, checked by applying the length function to all values in the cache.
+ * Default is Infinity
+ */
+ max?: number;
+
+ /**
+ * Maximum age in ms. Items are not pro-actively pruned out as they age,
+ * but if you try to get an item that is too old,
+ * it'll drop it and return undefined instead of giving it to you
+ */
+ maxAge?: number;
+
+ /**
+ * Function that is used to calculate the length of stored items
+ */
+ length?: LengthCalculator;
+
+ /**
+ * Function that is called on items when they are dropped from the cache
+ */
+ dispose?(key: K, value: V): void;
+
+ /**
+ * Whether to return the stale value before deleting it
+ */
+ stale?: boolean;
+
+ /**
+ * Dispose will only be called when a key falls out of the cache, not when it is overwritten
+ */
+ noDisposeOnSet?: boolean;
+ }
+
+ interface SerializedEntry {
+ /**
+ * key
+ */
+ key: K;
+
+ /**
+ * value
+ */
+ value: V;
+
+ /**
+ * when it becomes expired
+ */
+ e: number;
+ }
+
+ interface Entry {
+ /**
+ * key
+ */
+ key: K;
+
+ /**
+ * value
+ */
+ value: V;
+
+ /**
+ * entry length
+ */
+ length: number;
+
+ /**
+ * Timestamp when the entry was created
+ */
+ now: number;
+
+ /**
+ * Maximum live time
+ */
+ maxAge: number;
+ }
+ }
+
+ /**
+ * Represent an LRU cache
+ */
+ class LRU {
+ /**
+ * Creates an LRU cache of the given size
+ */
+ constructor(max: number);
+
+ /**
+ * Creates an LRU cache with the given options
+ */
+ constructor(options?: I.LRU.ConstructorOptions);
+
+ /**
+ * The length of the cache, setter resizes the cache
+ */
+ max: number;
+
+ /**
+ * stale setting
+ */
+ allowStale: boolean;
+
+ /**
+ * maxAge setting
+ */
+ maxAge: number;
+
+ /**
+ * length setting
+ */
+ lengthCalculator: I.LRU.LengthCalculator;
+
+ /**
+ * Total length of objects in cache taking into account length options function
+ */
+ readonly length: number;
+
+ /**
+ * Total quantity of objects currently in cache.
+ * Note, that stale items are returned as part of this item count.
+ */
+ readonly itemCount: number;
+
+ /**
+ * Iterates over all the keys in the cache, in reverse recent-ness order. (ie, less recently used items are iterated over first.)
+ */
+ rforEach(fn: (this: T, value: V, key: K, cache: LRU) => void, thisp?: T): void;
+
+ /**
+ * Iterates over all the keys in the cache, in order of recent-ness
+ */
+ forEach(fn: (this: T, value: V, key: K, cache: LRU) => void, thisp?: T): void;
+
+ /**
+ * Returns an array of the keys in the cache
+ */
+ keys(): K[];
+
+ /**
+ * Returns an array of the values in the cache
+ */
+ values(): V[];
+
+ /**
+ * Clears the cache entirely, throwing away all values
+ */
+ reset(): void;
+
+ /**
+ * Return an array of the cache entries ready for serialization and usage with 'destinationCache.load(arr)`
+ */
+ dump(): Array>;
+
+ /**
+ * Returns an internal lru list of entries
+ */
+ dumpLru(): LinkedList>;
+
+ /**
+ * @param opts std.util.inspect options
+ */
+ inspect(opts?: object): string;
+
+ /**
+ * Sets a new value for the given key. Updates the "recently used"-ness of the key
+ *
+ * @param maxAge maxAge option specific for this key
+ * @returns Whether the key was set
+ */
+ set(key: K, value: V, maxAge?: number): boolean;
+
+ /**
+ * Check if a key is in the cache, without updating the recent-ness or deleting it for being stale
+ */
+ has(key: K): boolean;
+
+ /**
+ * Gets the value of the given key. Updates the "recently used"-ness of the key
+ */
+ get(key: K): V | undefined;
+
+ /**
+ * Returns the key value without updating the "recently used"-ness of the key
+ */
+ peek(key: K): V | undefined;
+
+ /**
+ * Deletes the less recently used element
+ */
+ pop(): I.LRU.Entry;
+
+ /**
+ * Deletes a key out of the cache
+ */
+ del(key: K): void;
+
+ /**
+ * Loads another cache entries array, obtained with sourceCache.dump(), into the cache.
+ * The destination cache is reset before loading new entries
+ */
+ load(arr: Array>): void;
+
+ /**
+ * Manually iterates over the entire cache proactively pruning old entries
+ */
+ prune(): void;
+ }
+
+ /**
+ * Represents a Map that keeps keys only for a specified interval of time
+ */
+ class TimedoutMap extends Map {
+ /**
+ * @param timeout maximum age of the keys, 1000 by default
+ * @param callback callback that is called with each key when the timeout is passed
+ */
+ constructor(timeout?: number, callback?: (key: K) => void);
+
+ /**
+ * Gets the timeout
+ */
+ getTimeout(): number;
+
+ /**
+ * Sets the timeout
+ */
+ setTimeout(ms: number): void;
+
+ /**
+ * Iterates over the map and calls the callback for each element
+ */
+ forEach(callback: (this: T, value: V, key: K, cache: this) => void, thisArg?: T): this;
+
+ /**
+ * Deletes the given key
+ */
+ delete(key: K): boolean;
+ }
+ }
+}
diff --git a/types/adone/glosses/common.d.ts b/types/adone/glosses/common.d.ts
deleted file mode 100644
index 57025ea054..0000000000
--- a/types/adone/glosses/common.d.ts
+++ /dev/null
@@ -1,465 +0,0 @@
-/**
- * predicates
- */
-export namespace is {
- function _null(obj: any): boolean;
- export { _null as null };
- export function undefined(obj: any): boolean;
- export function exist(obj: any): boolean;
- export function nil(obj: any): boolean;
- export function number(obj: any): boolean;
- export function numeral(obj: any): boolean;
- export function infinite(obj: any): boolean;
- export function odd(obj: any): boolean;
- export function even(obj: any): boolean;
- export function float(obj: any): boolean;
- export function negativeZero(obj: any): boolean;
- export function string(obj: any): boolean;
- export function emptyString(obj: any): boolean;
- export function substring(substring: string, string: string, offset?: number): boolean;
- export function prefix(prefix: string, string: string): boolean;
- export function suffix(suffix: string, string: string): boolean;
- export function boolean(obj: any): boolean;
- export function json(obj: any): boolean;
- export function object(obj: any): boolean;
- export function plainObject(obj: any): boolean;
- function _class(obj: any): boolean;
- export { _class as class };
- export function emptyObject(obj: any): boolean;
- export function propertyOwned(obj: any, field: string): boolean;
- export function propertyDefined(obj: any, field: string): boolean;
- export function conforms(obj: object, schema: object, strict?: boolean): boolean;
- export function arrayLikeObject(obj: any): boolean;
- export function inArray(value: T, array: any[], offset?: number, comparator?: (a: T, b: T) => boolean): boolean;
- export function sameType(value: any, other: any): boolean;
- export function primitive(obj: any): boolean;
- export function equalArrays(left: any[], right: any[]): boolean;
- export function deepEqual(left: any, right: any): boolean;
- export function shallowEqual(left: any, right: any): boolean;
- export function stream(obj: any): boolean;
- export function writableStream(obj: any): boolean;
- export function readableStream(obj: any): boolean;
- export function duplexStream(obj: any): boolean;
- export function transformStream(obj: any): boolean;
- export function utf8(obj: Buffer): boolean;
- export function win32PathAbsolute(path: string): boolean;
- export function posixPathAbsolute(path: string): boolean;
- export function pathAbsolute(path: string): boolean;
- export function glob(str: string): boolean;
- export function dotfile(str: string): boolean;
- function _function(obj: any): boolean;
- export { _function as function };
- export function asyncFunction(obj: any): boolean;
- export function promise(obj: any): boolean;
- export function validDate(str: string): boolean;
- export function buffer(obj: any): boolean;
- export function callback(obj: any): boolean;
- export function generator(obj: any): boolean;
- export function nan(obj: any): boolean;
- export function finite(obj: any): boolean;
- export function integer(obj: any): boolean;
- export function safeInteger(obj: any): boolean;
- export function array(obj: any): boolean;
- export function uint8Array(obj: any): boolean;
- export function configuration(obj: any): boolean;
- export function long(obj: any): boolean;
- export function bigNumber(obj: any): boolean;
- export function exbuffer(obj: any): boolean;
- export function exdate(obj: any): boolean;
- export function transform(obj: any): boolean;
- export function subsystem(obj: any): boolean;
- export function application(obj: any): boolean;
- export function logger(obj: any): boolean;
- export function coreStream(obj: any): boolean;
- export function fastStream(obj: any): boolean;
- export function fastFSStream(obj: any): boolean;
- export function fastFSMapStream(obj: any): boolean;
- export function genesisNetron(obj: any): boolean;
- export function genesisPeer(obj: any): boolean;
- export function netronAdapter(obj: any): boolean;
- export function netron(obj: any): boolean;
- export function netronPeer(obj: any): boolean;
- export function netronDefinition(obj: any): boolean;
- export function netronDefinitions(obj: any): boolean;
- export function netronReference(obj: any): boolean;
- export function netronInterface(obj: any): boolean;
- export function netronContext(obj: any): boolean;
- export function netronIMethod(netronInterface: object, name: string): boolean;
- export function netronIProperty(netronInterface: any, name: string): boolean;
- export function netronStub(obj: any): boolean;
- export function netronRemoteStub(obj: any): boolean;
- export function netronStream(obj: any): boolean;
- export function iterable(obj: any): boolean;
- export const windows: boolean;
- export const linux: boolean;
- export const freebsd: boolean;
- export const darwin: boolean;
- export const sunos: boolean;
- export function uppercase(str: string): boolean;
- export function lowercase(str: string): boolean;
- export function digits(str: string): boolean;
- export function identifier(str: string): boolean;
- export function binaryExtension(str: string): boolean;
- export function binaryPath(str: string): boolean;
- export function ip4(str: string): boolean;
- export function ip6(str: string): boolean;
- export function arrayBuffer(obj: any): boolean;
- export function arrayBufferView(obj: any): boolean;
- export function date(obj: any): boolean;
- export function error(obj: any): boolean;
- export function map(obj: any): boolean;
- export function regexp(obj: any): boolean;
- export function set(obj: any): boolean;
- export function symbol(obj: any): boolean;
- export function validUTF8(obj: any): boolean;
-}
-
-export namespace x {
- class Exception extends Error {
- constructor(message?: string | Error, captureStackTrace?: boolean);
- }
- class Runtime extends Exception { }
- class IncompleteBufferError extends Exception { }
- class NotImplemented extends Exception { }
- class IllegalState extends Exception { }
- class NotValid extends Exception { }
- class Unknown extends Exception { }
- class NotExists extends Exception { }
- class Exists extends Exception { }
- class Empty extends Exception { }
- class InvalidAccess extends Exception { }
- class NotSupported extends Exception { }
- class InvalidArgument extends Exception { }
- class InvalidNumberOfArguments extends Exception { }
- class NotFound extends Exception { }
- class Timeout extends Exception { }
- class Incorrect extends Exception { }
- class NotAllowed extends Exception { }
- class LimitExceeded extends Exception { }
- class Encoding extends Exception { }
- class Network extends Exception { }
- class Bind extends Exception { }
- class Connect extends Exception { }
- class Database extends Exception { }
- class DatabaseInitialization extends Exception { }
- class DatabaseOpen extends Exception { }
- class DatabaseRead extends Exception { }
- class DatabaseWrite extends Exception { }
- class NetronIllegalState extends Exception { }
- class NetronPeerDisconnected extends Exception { }
- class NetronTimeout extends Exception { }
-}
-
-export class EventEmitter {
- static listenerCount(emitter: EventEmitter, event: string | symbol): number;
- static defaultMaxListeners: number;
-
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
- on(event: string | symbol, listener: (...args: any[]) => void): this;
- once(event: string | symbol, listener: (...args: any[]) => void): this;
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
- removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
- removeAllListeners(event?: string | symbol): this;
- setMaxListeners(n: number): this;
- getMaxListeners(): number;
- listeners(event: string | symbol): Array<(...args: any[]) => any>;
- emit(event: string | symbol, ...args: any[]): boolean;
- eventNames(): Array;
- listenerCount(type: string | symbol): number;
-}
-
-export class AsyncEmitter extends EventEmitter {
- constructor(concurrency?: number);
-
- setConcurrency(max?: number): this;
-
- emitParallel(event: string, ...args: any[]): Promise;
-
- emitSerial(event: string, ...args: any[]): Promise;
-
- emitReduce(event: string, ...args: any[]): Promise;
-
- emitReduceRight(event: string, ...args: any[]): Promise;
-
- subscribe(event: string, listener: (...args: any[]) => void, once?: boolean): () => void;
-}
-
-declare namespace I {
- type Long = adone.math.Long;
-
- type Longable = adone.math.I.Longable;
-
- namespace ExBuffer {
- interface Varint32 {
- value: number;
- length: number;
- }
-
- interface Varint64 {
- value: Long;
- length: number;
- }
-
- interface String {
- string: string;
- length: number;
- }
-
- type Wrappable = string | ExBuffer | Buffer | Uint8Array | ArrayBuffer;
-
- type METRICS = "b" | "c";
- }
-}
-
-export class ExBuffer {
- constructor(capacity?: number, noAssert?: boolean);
-
- readBitSet(offset?: number): number[];
-
- read(length: number, offset?: number): ExBuffer;
-
- readInt8(offset?: number): number;
-
- readUInt8(offset?: number): number;
-
- readInt16LE(offset?: number): number;
-
- readUInt16LE(offset?: number): number;
-
- readInt16BE(offset?: number): number;
-
- readUInt16BE(offset?: number): number;
-
- readInt32LE(offset?: number): number;
-
- readUInt32LE(offset?: number): number;
-
- readInt32BE(offset?: number): number;
-
- readUInt32BE(offset?: number): number;
-
- readInt64LE(offset?: number): adone.math.Long;
-
- readUInt64LE(offset?: number): adone.math.Long;
-
- readInt64BE(offset?: number): adone.math.Long;
-
- readUInt64BE(offset?: number): adone.math.Long;
-
- readFloatLE(offset?: number): number;
-
- readFloatBE(offset?: number): number;
-
- readDoubleLE(offset?: number): number;
-
- readDoubleBE(offset?: number): number;
-
- write(source: I.ExBuffer.Wrappable, offset?: number, length?: number, encoding?: string): this;
-
- writeBitSet(value: number[]): this;
-
- writeBitSet(value: number[], offset: number): number;
-
- writeInt8(value: number, offset?: number): this;
-
- writeUInt8(value: number, offset?: number): this;
-
- writeInt16LE(value: number, offset?: number): this;
-
- writeInt16BE(value: number, offset?: number): this;
-
- writeUInt16LE(value: number, offset?: number): this;
-
- writeUInt16BE(value: number, offset?: number): this;
-
- writeInt32LE(value: number, offset?: number): this;
-
- writeInt32BE(value: number, offset?: number): this;
-
- writeUInt32LE(value: number, offset?: number): this;
-
- writeUInt32BE(value: number, offset?: number): this;
-
- writeInt64LE(value: I.Longable, offset?: number): this;
-
- writeInt64BE(value: I.Longable, offset?: number): this;
-
- writeUInt64LE(value: I.Longable, offset?: number): this;
-
- writeUInt64BE(value: I.Longable, offset?: number): this;
-
- writeFloatLE(value: number, offset?: number): this;
-
- writeFloatBE(value: number, offset?: number): this;
-
- writeDoubleLE(value: number, offset?: number): this;
-
- writeDoubleBE(value: number, offset?: number): this;
-
- writeVarint32(value: number): this;
-
- writeVarint32(value: number, offset: number): number;
-
- writeVarint32ZigZag(value: number): this;
-
- writeVarint32ZigZag(value: number, offset: number): number;
-
- readVarint32(): number;
-
- readVarint32(offset: number): I.ExBuffer.Varint32;
-
- readVarint32ZigZag(): number;
-
- readVarint32ZigZag(offset: number): I.ExBuffer.Varint32;
-
- writeVarint64(value: I.Longable): this;
-
- writeVarint64(value: I.Longable, offset: number): number;
-
- writeVarint64ZigZag(value: I.Longable): this;
-
- writeVarint64ZigZag(value: I.Longable, offset: number): number;
-
- readVarint64(): I.Long;
-
- readVarint64(offset: number): I.ExBuffer.Varint64;
-
- readVarint64ZigZag(): adone.math.Long;
-
- readVarint64ZigZag(offset: number): I.ExBuffer.Varint64;
-
- writeCString(str: string): this;
-
- writeCString(str: string, offset: number): number;
-
- readCString(): string;
-
- readCString(offset: number): I.ExBuffer.String;
-
- writeString(str: string): this;
-
- writeString(str: string, offset: number): number;
-
- readString(length: number, metrics?: I.ExBuffer.METRICS): string;
-
- readString(length: number, metrics: I.ExBuffer.METRICS, offset: number): I.ExBuffer.String;
-
- readString(length: number, offset: number): I.ExBuffer.String;
-
- writeVString(str: string): this;
-
- writeVString(str: string, offset: number): number;
-
- readVString(): string;
-
- readVString(offset: number): I.ExBuffer.String;
-
- appendTo(target: ExBuffer, offset?: number): this;
-
- assert(assert?: boolean): this;
-
- capacity(): number;
-
- clear(): this;
-
- compact(begin?: number, end?: number): this;
-
- copy(begin?: number, end?: number): ExBuffer;
-
- copyTo(target: ExBuffer, targetOffset?: number, souceOffset?: number, sourceLimit?: number): this | ExBuffer;
-
- ensureCapacity(capacity: number): this;
-
- fill(value: string | number, begin?: number, end?: number): this;
-
- flip(): this;
-
- mark(offset?: number): this;
-
- prepend(source: I.ExBuffer.Wrappable, encoding?: string, offset?: number): this;
-
- prepend(source: I.ExBuffer.Wrappable, offset: number): this;
-
- prependTo(target: ExBuffer, offset?: number): this;
-
- remaining(): number;
-
- reset(): this;
-
- resize(capacity: number): this;
-
- reverse(begin?: number, end?: number): this;
-
- skip(length: number): this;
-
- slice(begin?: number, end?: number): ExBuffer;
-
- toBuffer(forceCopy?: boolean, begin?: number, end?: number): Buffer;
-
- toArrayBuffer(): ArrayBuffer;
-
- toString(encoding?: string, begin?: number, end?: number): string;
-
- toBase64(begin?: number, end?: number): string;
-
- toBinary(begin?: number, end?: number): string;
-
- toDebug(columns?: boolean): string;
-
- toHex(begin?: number, end?: number): string;
-
- toUTF8(begin?: number, end?: number): string;
-
- static accessor(): typeof Buffer;
-
- static allocate(capacity?: number, noAssert?: boolean): ExBuffer;
-
- static concat(buffers: I.ExBuffer.Wrappable[], encoding?: string, noAssert?: boolean): ExBuffer;
-
- static type(): typeof Buffer;
-
- static wrap(buffer: I.ExBuffer.Wrappable, encoding?: string, noAssert?: boolean): ExBuffer;
-
- static calculateVarint32(value: number): number;
-
- static zigZagEncode32(n: number): number;
-
- static zigZagDecode32(n: number): number;
-
- static calculateVarint64(value: number | string): number;
-
- static zigZagEncode64(value: number | string | I.Long): I.Long;
-
- static zigZagDecode64(value: number | string | I.Long): I.Long;
-
- static calculateUTF8Chars(str: string): number;
-
- static calculateString(str: string): number;
-
- static fromBase64(str: string): ExBuffer;
-
- static btoa(str: string): string;
-
- static atob(b64: string): string;
-
- static fromBinary(str: string): ExBuffer;
-
- static fromDebug(str: string, noAssert?: boolean): ExBuffer;
-
- static fromHex(str: string, noAssert?: boolean): ExBuffer;
-
- static fromUTF8(str: string, noAssert?: boolean): ExBuffer;
-
- static DEFAULT_CAPACITY: number;
-
- static DEFAULT_NOASSERT: boolean;
-
- static MAX_VARINT32_BYTES: number;
-
- static MAX_VARINT64_BYTES: number;
-
- static METRICS_CHARS: string;
-
- static METRICS_BYTES: string;
-}
diff --git a/types/adone/glosses/compressors.d.ts b/types/adone/glosses/compressors.d.ts
new file mode 100644
index 0000000000..963eddc99d
--- /dev/null
+++ b/types/adone/glosses/compressors.d.ts
@@ -0,0 +1,1137 @@
+declare namespace adone {
+ /**
+ * Various compressors
+ */
+ namespace compressor {
+ namespace I {
+ namespace zlib {
+ type TypedArray = Int8Array | Uint8Array
+ | Uint8ClampedArray
+ | Int16Array | Uint16Array
+ | Int32Array | Uint32Array
+ | Float32Array | Float64Array;
+
+ interface CommonOptions {
+ flush?: number;
+ finishFlush?: number;
+ chunkSize?: number;
+
+ /**
+ * The base two logarithm of the window size (the size of the history buffer).
+ * It should be in the range 8..15.
+ * Larger values of this parameter result in better compression at the expense of memory usage.
+ */
+ windowBits?: number;
+ }
+
+ interface CompressStreamOptions extends CommonOptions {
+ /**
+ * The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
+ * 1 gives best speed,
+ * 9 gives best compression,
+ * 0 gives no compression at all (the input data is simply copied a block at a time).
+ * Z_DEFAULT_COMPRESSION requests a default compromise between speed and compression (currently equivalent to level 6)
+ */
+ level?: number;
+
+ /**
+ * How much memory should be allocated for the internal compression state
+ *
+ * memLevel=1 uses minimum memory but is slow and reduces compression ratio
+ *
+ * memLevel=9 uses maximum memory for optimal speed
+ */
+ memLevel?: number;
+
+ /**
+ * Used to tune the compression algorithm.
+ *
+ * Use the value Z_DEFAULT_STRATEGY for normal data,
+ * Z_FILTERED for data produced by a filter (or predictor),
+ * Z_HUFFMAN_ONLY to force Huffman encoding only (no string match),
+ * or Z_RLE to limit match distances to one (run-length encoding).
+ */
+ strategy?: number;
+ }
+
+ type DecompressStreamOptions = CommonOptions;
+
+ interface CompressOptions extends CompressStreamOptions {
+ /**
+ * If true, returns an object with buffer and engine
+ */
+ info?: boolean;
+ }
+
+ interface DecompressOptions extends DecompressStreamOptions {
+ /**
+ * If true, returns an object with buffer and engine
+ */
+ info?: boolean;
+ }
+
+ interface Info {
+ buffer: Buffer;
+ engine: T;
+ }
+
+ type GzipInfo = Info;
+
+ type GunzipInfo = Info;
+
+ type DeflateInfo = Info;
+
+ type DeflateRawInfo = Info;
+
+ type InflateInfo = Info;
+
+ type InflateRawInfo = Info;
+ }
+ }
+ /**
+ * GZIP compressor
+ */
+ namespace gz {
+ /**
+ * Compresses the given string or buffer
+ */
+ function compress(buf: string | Buffer, options: I.zlib.CompressOptions & { info: true }): Promise;
+
+ /**
+ * Compresses the given string or buffer
+ */
+ function compress(buf: string | Buffer, options?: I.zlib.CompressOptions): Promise;
+
+ /**
+ * Synchronously compreses the given string or buffer
+ */
+ function compressSync(buf: string | Buffer, options: I.zlib.CompressOptions & { info: true }): I.zlib.GzipInfo;
+
+ /**
+ * Synchronously compreses the given string or buffer
+ */
+ function compressSync(buf: string | Buffer, options?: I.zlib.CompressOptions): Buffer;
+
+ /**
+ * Creates a compress stream
+ */
+ function compressStream(options?: I.zlib.CompressStreamOptions): nodestd.zlib.Gzip;
+
+ /**
+ * Decompresses the given string or buffer
+ */
+ function decompress(buf: string | Buffer, options: I.zlib.DecompressOptions & { info: true }): Promise;
+
+ /**
+ * Decompresses the given string or buffer
+ */
+ function decompress(buf: string | Buffer, options?: I.zlib.DecompressOptions): Promise;
+
+ /**
+ * Synchronously decompresses the given string or buffer
+ */
+ function decompressSync(buf: string | Buffer, options: I.zlib.DecompressOptions & { info: true }): I.zlib.GunzipInfo;
+
+ /**
+ * Synchronously decompresses the given string or buffer
+ */
+ function decompressSync(buf: string | Buffer, options?: I.zlib.DecompressOptions): Buffer;
+
+ /**
+ * Creates a decompress stream
+ */
+ function decompressStream(options?: I.zlib.DecompressStreamOptions): nodestd.zlib.Gunzip;
+
+ const Z_NO_FLUSH: number;
+ const Z_PARTIAL_FLUSH: number;
+ const Z_SYNC_FLUSH: number;
+ const Z_FULL_FLUSH: number;
+ const Z_FINISH: number;
+ const Z_BLOCK: number;
+ const Z_TREES: number;
+
+ const Z_OK: number;
+ const Z_STREAM_END: number;
+ const Z_NEED_DICT: number;
+ const Z_ERRNO: number;
+ const Z_STREAM_ERROR: number;
+ const Z_DATA_ERROR: number;
+ const Z_MEM_ERROR: number;
+ const Z_BUF_ERROR: number;
+ const Z_VERSION_ERROR: number;
+
+ const Z_NO_COMPRESSION: number;
+ const Z_BEST_SPEED: number;
+ const Z_BEST_COMPRESSION: number;
+ const Z_DEFAULT_COMPRESSION: number;
+
+ const Z_FILTERED: number;
+ const Z_HUFFMAN_ONLY: number;
+ const Z_RLE: number;
+ const Z_FIXED: number;
+ const Z_DEFAULT_STRATEGY: number;
+ }
+
+ /**
+ * Deflate compressor
+ */
+ namespace deflate {
+ namespace I {
+ interface CompressStreamOptions extends compressor.I.zlib.CompressStreamOptions {
+ dictionary?: Buffer | DataView | compressor.I.zlib.TypedArray;
+ }
+
+ interface DecompressStreamOptions extends compressor.I.zlib.DecompressStreamOptions {
+ dictionary?: Buffer | DataView | compressor.I.zlib.TypedArray;
+ }
+
+ interface CompressOptions extends CompressStreamOptions {
+ /**
+ * If true, returns an object with buffer and engine
+ */
+ info?: boolean;
+ }
+
+ interface DecompressOptions extends DecompressStreamOptions {
+ /**
+ * If true, returns an object with buffer and engine
+ */
+ info?: boolean;
+ }
+
+ type DeflateInfo = compressor.I.zlib.DeflateInfo;
+
+ type DeflateRawInfo = compressor.I.zlib.DeflateRawInfo;
+
+ type InflateInfo = compressor.I.zlib.InflateInfo;
+
+ type InflateRawInfo = compressor.I.zlib.InflateRawInfo;
+ }
+
+ /**
+ * Compresses the given string or buffer
+ */
+ function compress(buf: string | Buffer, options: I.CompressOptions & { info: true }): Promise;
+
+ /**
+ * Compresses the given string or buffer
+ */
+ function compress(buf: string | Buffer, options?: I.CompressOptions): Promise;
+
+ /**
+ * Synchronously compresses the given string or buffer
+ */
+ function compressSync(buf: string | Buffer, options: I.CompressOptions & { info: true }): I.DeflateInfo;
+
+ /**
+ * Synchronously compresses the given string or buffer
+ */
+ function compressSync(buf: string | Buffer, options?: I.CompressOptions): Buffer;
+
+ /**
+ * Creates a compress stream
+ */
+ function compressStream(options?: I.CompressStreamOptions): nodestd.zlib.Deflate;
+
+ /**
+ * Compresses data using deflate, and does not append a zlib header
+ */
+ function rawCompress(buf: string | Buffer, options: I.CompressOptions & { info: true }): Promise;
+
+ /**
+ * Compresses data using deflate, and does not append a zlib header
+ */
+ function rawCompress(buf: string | Buffer, options?: I.CompressOptions): Promise;
+
+ /**
+ * Synchronously compresses data using deflate, and does not append a zlib header
+ */
+ function rawCompressSync(buf: string | Buffer, options: I.CompressOptions & { info: true }): I.DeflateRawInfo;
+
+ /**
+ * Synchronously compresses data using deflate, and does not append a zlib header
+ */
+ function rawCompressSync(buf: string | Buffer, options?: I.CompressOptions): Buffer;
+
+ /**
+ * Creates a raw compress stream
+ */
+ function rawCompressStream(options?: I.CompressStreamOptions): nodestd.zlib.DeflateRaw;
+
+ /**
+ * Decomrpesses the given string of buffer
+ */
+ function decompress(buf: string | Buffer, options: I.DecompressOptions & { info: true }): Promise;
+
+ /**
+ * Decomrpesses the given string of buffer
+ */
+ function decompress(buf: string | Buffer, options?: I.DecompressOptions): Promise;
+
+ /**
+ * Synchronously decomrpesses the given string of buffer
+ */
+ function decompressSync(buf: string | Buffer, options: I.DecompressOptions & { info: true }): I.InflateInfo;
+
+ /**
+ * Synchronously decomrpesses the given string of buffer
+ */
+ function decompressSync(buf: string | Buffer, options?: I.DecompressOptions): Buffer;
+
+ /**
+ * Creates a decompress stream
+ */
+ function decompressStream(options?: I.DecompressStreamOptions): nodestd.zlib.Inflate;
+
+ /**
+ * Decompresses raw compressed data
+ */
+ function rawDecompress(buf: string | Buffer, options: I.DecompressOptions & { info: true }): Promise;
+
+ /**
+ * Decompresses raw compressed data
+ */
+ function rawDecompress(buf: string | Buffer, options?: I.DecompressOptions): Promise;
+
+ /**
+ * Synchronously decompresses raw compressed data
+ */
+ function rawDecompressSync(buf: string | Buffer, options: I.DecompressOptions & { info: true }): I.InflateRawInfo;
+
+ /**
+ * Synchronously decompresses raw compressed data
+ */
+ function rawDecompressSync(buf: string | Buffer, options?: I.DecompressOptions): Buffer;
+
+ /**
+ * Creates a raw decompress stream
+ */
+ function rawDecompressStream(options?: I.DecompressStreamOptions): nodestd.zlib.InflateRaw;
+
+ const Z_NO_FLUSH: number;
+ const Z_PARTIAL_FLUSH: number;
+ const Z_SYNC_FLUSH: number;
+ const Z_FULL_FLUSH: number;
+ const Z_FINISH: number;
+ const Z_BLOCK: number;
+ const Z_TREES: number;
+
+ const Z_OK: number;
+ const Z_STREAM_END: number;
+ const Z_NEED_DICT: number;
+ const Z_ERRNO: number;
+ const Z_STREAM_ERROR: number;
+ const Z_DATA_ERROR: number;
+ const Z_MEM_ERROR: number;
+ const Z_BUF_ERROR: number;
+ const Z_VERSION_ERROR: number;
+
+ const Z_NO_COMPRESSION: number;
+ const Z_BEST_SPEED: number;
+ const Z_BEST_COMPRESSION: number;
+ const Z_DEFAULT_COMPRESSION: number;
+
+ const Z_FILTERED: number;
+ const Z_HUFFMAN_ONLY: number;
+ const Z_RLE: number;
+ const Z_FIXED: number;
+ const Z_DEFAULT_STRATEGY: number;
+ }
+
+ /**
+ * Brotli compressor (br)
+ */
+ namespace brotli {
+ namespace I {
+ interface CompressOptions {
+ /**
+ * Tune encoder for specific input.
+ *
+ * 0 - Generic mode, compressor does not know anything in advance about the properties of the input.
+ *
+ * 1 - Text mode, compression mode for UTF-8 formatted text input.
+ *
+ * 2 - Font, compression mode used in WOFF 2.0.
+ *
+ * Default is 0.
+ */
+ mode?: number;
+
+ /**
+ * The main compression speed-density lever.
+ * The higher the quality, the slower the compression.
+ * From 0 to 11.
+ *
+ * Default is 11.
+ */
+ quality?: number;
+
+ /**
+ * Recommended sliding LZ77 window size.
+ * Encoder may reduce this value, e.g. if input is much smaller than window size.
+ * Window size is (1 << value) - 16.
+ * From 10 to 24.
+ *
+ * Default is 22.
+ */
+ lgwin?: number;
+
+ /**
+ * Recommended input block size.
+ * Encoder may reduce this value, e.g. if input is much smaller than input block size.
+ * Bigger input block size allows better compression, but consumes more memory.
+ * From 16 to 24.
+ */
+ lgblock?: number;
+
+ /**
+ * Estimated total input size for all BrotliEncoderCompressStream calls.
+ *
+ * Automatically set for `compress` and `compressSync` to the input buffer length
+ */
+ size_hint?: number;
+
+ /**
+ * Flag that affects usage of "literal context modeling" format feature.
+ * This flag is a "decoding-speed vs compression ratio" trade-off.
+ */
+ disable_literal_context_modeling?: boolean;
+
+ /**
+ * A custom dictionary
+ */
+ dictionary?: Buffer;
+ }
+
+ interface DecompressOptions {
+ /**
+ * A custom dictionary
+ */
+ dictionary?: Buffer;
+ }
+
+ interface EncodeStream extends nodestd.stream.Transform {
+ flush(force?: boolean): void;
+ }
+
+ type DecodeStream = nodestd.stream.Transform;
+ }
+
+ /**
+ * Compresses the given string or buffer
+ */
+ function compress(buf: string | Buffer, options?: I.CompressOptions): Promise;
+
+ /**
+ * Synchronously compresses the given string or buffer
+ */
+ function compressSync(buf: string | Buffer, options?: I.CompressOptions): Buffer;
+
+ /**
+ * Creates a compress stream
+ */
+ function compressStream(options?: I.CompressOptions): I.EncodeStream;
+
+ /**
+ * Decompresses the given buffer
+ */
+ function decompress(buf: Buffer, options?: I.DecompressOptions): Promise;
+
+ /**
+ * Synchronously decompresses the given buffer
+ */
+ function decompressSync(buf: Buffer, options?: I.DecompressOptions): Buffer;
+
+ /**
+ * Creates a decompress stream
+ */
+ function decompressStream(options?: I.DecompressOptions): I.DecodeStream;
+ }
+
+ /**
+ * Snappy compressor
+ */
+ namespace snappy {
+ /**
+ * Compresses the given string or buffer
+ */
+ function compress(buf: string | Buffer): Promise;
+
+ /**
+ * Synchronously compresses the given string or buffer
+ */
+ function compressSync(buf: string | Buffer): Buffer;
+
+ /**
+ * Checks whether the given buffer is a valid compressed buffer
+ */
+ function isValidCompressed(buf: Buffer): Promise;
+
+ /**
+ * Synchronously checks whether the given buffer is a valid compressed buffer
+ */
+ function isValidCompressedSync(buf: Buffer): boolean;
+
+ /**
+ * Decompresses the given buffer
+ */
+ function decompress(buf: Buffer): Promise;
+
+ /**
+ * Synchronously decompresses the given buffer
+ */
+ function decompressSync(buf: Buffer): Buffer;
+ }
+
+ namespace I.lzma {
+ interface Filter {
+ id: "LZMA_FILTERS_MAX"
+ | "LZMA_FILTER_ARM"
+ | "LZMA_FILTER_ARMTHUMB"
+ | "LZMA_FILTER_IA64"
+ | "LZMA_FILTER_POWERPC"
+ | "LZMA_FILTER_SPARC"
+ | "LZMA_FILTER_X86"
+ | "LZMA_FILTER_LZMA1"
+ | "LZMA_FILTER_LZMA2";
+ }
+
+ interface DeltaFilter {
+ id: "LZMA_FILTER_DELTA";
+ dist?: number;
+ }
+
+ interface LZMAFilter {
+ id: "LZMA_FILTER_LZMA1" | "LZMA_FILTER_LZMA2";
+
+ /**
+ * Dictionary size indicates how many bytes of the recently processed
+ * uncompressed data is kept in memory.
+ */
+ dict_size?: number;
+
+ /**
+ * The number of literal position bits.
+ * From 0 to 4.
+ * Default is 0.
+ * In addition, the sum of lc and lp must not exceed 4.
+ */
+ lp?: number;
+
+ /**
+ * The number of literal context bits.
+ * From 0 to 4.
+ * Default is 3.
+ * In addition, the sum of lc and lp must not exceed 4.
+ */
+ lc?: number;
+
+ /**
+ * The number of position bits.
+ * From 0 to 4.
+ * Default is 2.
+ */
+ pb?: number;
+
+ /**
+ * Compression mode
+ *
+ * lzma.MODE_FAST - 1
+ *
+ * lzma.MODE_NORMAL - 2
+ */
+ mode?: number;
+
+ /**
+ * Specify what is considered to be a nice length for a match.
+ * Once a match of at least nice bytes is found, the algorithm stops looking for possibly better matches.
+ * From 2 to 273.
+ * Default is 64.
+ */
+ nice_len?: number;
+
+ /**
+ * Match finder has major effect on both speed and compression ratio.
+ * Usually hash chains are faster than binary trees.
+ *
+ * MF_HC3 - 3
+ *
+ * MF_HC4 - 4
+ *
+ * MF_BT2 - 18
+ *
+ * MF_BT3 - 19
+ *
+ * MF_BT4 - 201
+ *
+ */
+ mf?: number;
+
+ /**
+ * Specify the maximum search depth in the match finder.
+ * The default is the special value of 0, which makes the
+ * compressor determine a reasonable depth from mf and nice.
+ *
+ * Reasonable depth for Hash Chains is 4-100 and 16-1000 for Binary Trees.
+ */
+ depth?: number;
+
+ /**
+ * A number from 0 to 9, 0 being the fastest and weakest compression,
+ * 9 the slowest and highest compression level
+ */
+ preset?: number;
+ }
+
+ type Filters = Array;
+
+ type Coder = "easyEncoder"
+ | "autoDecoder"
+ | "aloneEncoder"
+ | "aloneDecoder"
+ | "rawEncoder"
+ | "rawDecoder"
+ | "streamEncoder"
+ | "streamDecoder";
+
+ interface AloneEncoderOptions {
+ /**
+ * Any of:
+ *
+ * CHECK_CRC32 (1)
+ *
+ * CHECK_CRC64 (4)
+ *
+ * CHECK_NONE (0)
+ *
+ * CHECK_SHA256 (10)
+ */
+ check?: number;
+
+ /**
+ * A memory limit for (de-)compression in bytes
+ */
+ memlimit?: number;
+
+ /**
+ * A number from 0 to 9, 0 being the fastest and weakest compression, 9 the slowest and highest compression level
+ */
+ preset?: number;
+
+ /**
+ * A bitwise OR of
+ * LZMA_TELL_NO_CHECK,
+ * LZMA_TELL_UNSUPPORTED_CHECK,
+ * LZMA_TELL_ANY_CHECK,
+ * LZMA_CONCATENATED
+ */
+ flags?: number;
+
+ /**
+ * If true, forces synchronous coding (i.e. no usage of threading)
+ */
+ synchronous?: boolean;
+
+ /**
+ * The default size for allocated buffers
+ */
+ bufsize?: number;
+
+ /**
+ * Set to an integer to use liblzma’s multi-threading support. 0 will choose the number of CPU cores.
+ */
+ threads?: number;
+
+ /**
+ * Maximum uncompressed size of a block in multi-threading mode
+ */
+ blockSize?: number;
+
+ /**
+ * Timeout for a single encoding operation in multi-threading mode
+ */
+ timeout?: number;
+
+ /**
+ * An array of additional filters
+ */
+ filters?: Filters;
+ }
+
+ interface Stream extends nodestd.stream.Transform {
+ bufsize: number;
+
+ totalIn(): number;
+
+ totalOut(): number;
+
+ cleanup(): void;
+ }
+
+ interface EasyEncoderOptions {
+ /**
+ * A number from 0 to 9, 0 being the fastest and weakest compression, 9 the slowest and highest compression level
+ */
+ preset?: number;
+
+ /**
+ * Any of:
+ *
+ * CHECK_CRC32 (1)
+ *
+ * CHECK_CRC64 (4)
+ *
+ * CHECK_NONE (0)
+ *
+ * CHECK_SHA256 (10)
+ */
+ check?: number;
+ }
+
+ interface AutoDecoderOptions {
+ /**
+ * A memory limit for (de-)compression in bytes
+ */
+ memlimit?: number;
+
+ /**
+ * A bitwise OR of
+ * LZMA_TELL_NO_CHECK,
+ * LZMA_TELL_UNSUPPORTED_CHECK,
+ * LZMA_TELL_ANY_CHECK,
+ * LZMA_CONCATENATED
+ */
+ flags?: number;
+ }
+
+ interface AloneDecoderOptions {
+ /**
+ * A memory limit for (de-)compression in bytes
+ */
+ memlimit?: number;
+ }
+
+ interface RawEncoderOptions {
+ /**
+ * An array of additional filters
+ */
+ filters?: Filters;
+ }
+
+ interface RawDecoderOptions {
+ /**
+ * An array of additional filters
+ */
+ filters?: Filters;
+ }
+
+ interface StreamEncoderOptions {
+ /**
+ * Any of:
+ *
+ * CHECK_CRC32 (1)
+ *
+ * CHECK_CRC64 (4)
+ *
+ * CHECK_NONE (0)
+ *
+ * CHECK_SHA256 (10)
+ */
+ check?: number;
+
+ /**
+ * An array of additional filters
+ */
+ filters?: Filters;
+ }
+
+ interface StreamDecoderOptions {
+ /**
+ * A memory limit for (de-)compression in bytes
+ */
+ memlimit?: number;
+
+ /**
+ * A bitwise OR of
+ * LZMA_TELL_NO_CHECK,
+ * LZMA_TELL_UNSUPPORTED_CHECK,
+ * LZMA_TELL_ANY_CHECK,
+ * LZMA_CONCATENATED
+ */
+ flags?: number;
+ }
+ }
+
+ /**
+ * lzma compressor + common lzma functionality
+ */
+ namespace lzma {
+ const asyncCodeAvailable: boolean;
+
+ /**
+ * Returns the version of the underlying C library
+ */
+ function versionNumber(): number;
+
+ /**
+ * Returns the version of the underlying C library
+ */
+ function versionString(): string;
+
+ /**
+ * Checks whether the given Check ID is supported by this liblzma build
+ */
+ function checkIsSupported(check: number): boolean;
+
+ /**
+ * Return the byte size of a check sums
+ *
+ * @param check Any supported check constant
+ */
+ function checkSize(check: number): number;
+
+ /**
+ * Checks whether the given encoder filter is supported
+ */
+ function filterEncoderIsSupported(encoder: string): boolean;
+
+ /**
+ * Checks whether the given encoder filter is supported
+ */
+ function filterDecoderIsSupported(decoder: string): boolean;
+
+ /**
+ * Checks whether the given match finder is supported by this liblzma build
+ */
+ function mfIsSupported(mf: number): boolean;
+
+ /**
+ * Checks whether the given compression mode is supported by this liblzma build
+ */
+ function modeIsSupported(mode: number): boolean;
+
+ /**
+ * Returns the approximate memory usage when encoding using rawEncoder for a given filter list
+ */
+ function rawEncoderMemusage(filters: I.lzma.Filters): number;
+
+ /**
+ * Returns the approximate memory usage when decoding using rawDecoder for a given filter list
+ */
+ function rawDecoderMemusage(filters: I.lzma.Filters): number;
+
+ /**
+ * Returns the approximate memory usage when encoding using easyEncoder for a given preset
+ */
+ function easyEncoderMemusage(preset: number): number;
+
+ /**
+ * Returns the approximate memory usage when decoding using easyDecoder for a given preset
+ */
+ function easyDecoderMemusage(preset: number): number;
+
+ /**
+ * Returns a standard LZMA2 (.xz) encoder
+ *
+ * @param options preset or options
+ */
+ function createStream(coder: "easyEncoder", options?: number | I.lzma.EasyEncoderOptions): I.lzma.Stream;
+
+ /**
+ * Returns a standard LZMA 1/2 (bith .xz and .lzma) decoder with auto detection of file format
+ *
+ * @param options preset or options
+ */
+ function createStream(coder: "autoDecoder", options?: I.lzma.AutoDecoderOptions): I.lzma.Stream;
+
+ /**
+ * Returns a standard LZMA encoder
+ *
+ * @param options preset or options
+ */
+ function createStream(coder: "aloneEncoder", options?: number | I.lzma.AloneEncoderOptions): I.lzma.Stream;
+
+ /**
+ * Returns a standard LZMA decoder
+ */
+ function createStream(coder: "aloneDecoder", options?: I.lzma.AloneDecoderOptions): I.lzma.Stream;
+
+ /**
+ * Returns a custom encoder corresponding to lzma_raw_encoder
+ */
+ function createStream(coder: "rawEncoder", options?: I.lzma.RawEncoderOptions): I.lzma.Stream;
+
+ /**
+ * Returns a custom decoder corresponding to lzma_raw_decoder
+ */
+ function createStream(coder: "rawDecoder", options?: I.lzma.RawDecoderOptions): I.lzma.Stream;
+
+ /**
+ * Returns a custom encoder corresponding to lzma_stream_encoder
+ */
+ function createStream(coder: "streamEncoder", options?: I.lzma.StreamEncoderOptions): I.lzma.Stream;
+
+ /**
+ * Returns a custom decoder corresponding to lzma_stream_decoder
+ */
+ function createStream(coder: "streamDecoder", options?: I.lzma.StreamDecoderOptions): I.lzma.Stream;
+
+ /**
+ * Encodes the given string or buffer using the given stream
+ */
+ function singleStringCoding(
+ stream: I.lzma.Stream,
+ string: string | Buffer,
+ onFinish?: (err: any, data: Buffer) => void,
+ onProgress?: (progress: number) => void
+ ): Promise;
+
+ const CHECK_CRC32: number;
+ const CHECK_CRC64: number;
+ const CHECK_NONE: number;
+ const CHECK_SHA256: number;
+
+ const FILTERS_MAX: string;
+ const FILTER_ARM: string;
+ const FILTER_ARMTHUMB: string;
+ const FILTER_IA64: string;
+ const FILTER_POWERPC: string;
+ const FILTER_SPARC: string;
+ const FILTER_X86: string;
+ const FILTER_DELTA: string;
+ const FILTER_LZMA1: string;
+ const FILTER_LZMA2: string;
+
+ const PRESET_EXTREME: number;
+ const PRESET_DEFAULT: number;
+ const PRESET_LEVEL_MASK: number;
+
+ const MF_HC3: number;
+ const MF_HC4: number;
+ const MF_BT2: number;
+ const MF_BT3: number;
+ const MF_BT4: number;
+
+ const LZMA_TELL_NO_CHECK: number;
+ const LZMA_TELL_UNSUPPORTED_CHECK: number;
+ const LZMA_TELL_ANY_CHECK: number;
+ const LZMA_CONCATENATED: number;
+
+ const MODE_FAST: number;
+ const MODE_NORMAL: number;
+
+ const STREAM_HEADER_SIZE: number;
+
+ /**
+ * Compresses the given string or buffer
+ *
+ * @param options preset or options
+ */
+ function compress(buf: string | Buffer, options?: number | I.lzma.AloneEncoderOptions): Promise;
+
+ /**
+ * Creates a compress stream
+ *
+ * @param options preset or options
+ */
+ function compressStream(options?: number | I.lzma.AloneEncoderOptions): I.lzma.Stream;
+
+ /**
+ * Decompresses the given buffer
+ */
+ function decompress(buf: Buffer, options?: I.lzma.AloneDecoderOptions): Promise;
+
+ /**
+ * Creates a decompress stream
+ *
+ * @param options preset or options
+ */
+ function decompressStream(options?: I.lzma.AloneDecoderOptions): I.lzma.Stream;
+ }
+
+ /**
+ * xz compressor (lzma2) + common lzma functionality
+ */
+ namespace xz {
+ const asyncCodeAvailable: boolean;
+
+ /**
+ * Returns the version of the underlying C library
+ */
+ function versionNumber(): number;
+
+ /**
+ * Returns the version of the underlying C library
+ */
+ function versionString(): string;
+
+ /**
+ * Checks whether the given Check ID is supported by this liblzma build
+ */
+ function checkIsSupported(check: number): boolean;
+
+ /**
+ * Return the byte size of a check sums
+ *
+ * @param check Any supported check constant
+ */
+ function checkSize(check: number): number;
+
+ /**
+ * Checks whether the given encoder filter is supported
+ */
+ function filterEncoderIsSupported(encoder: string): boolean;
+
+ /**
+ * Checks whether the given encoder filter is supported
+ */
+ function filterDecoderIsSupported(decoder: string): boolean;
+
+ /**
+ * Checks whether the given match finder is supported by this liblzma build
+ */
+ function mfIsSupported(mf: number): boolean;
+
+ /**
+ * Checks whether the given compression mode is supported by this liblzma build
+ */
+ function modeIsSupported(mode: number): boolean;
+
+ /**
+ * Returns the approximate memory usage when encoding using rawEncoder for a given filter list
+ */
+ function rawEncoderMemusage(filters: I.lzma.Filters): number;
+
+ /**
+ * Returns the approximate memory usage when decoding using rawDecoder for a given filter list
+ */
+ function rawDecoderMemusage(filters: I.lzma.Filters): number;
+
+ /**
+ * Returns the approximate memory usage when encoding using easyEncoder for a given preset
+ */
+ function easyEncoderMemusage(preset: number): number;
+
+ /**
+ * Returns the approximate memory usage when decoding using easyDecoder for a given preset
+ */
+ function easyDecoderMemusage(preset: number): number;
+
+ /**
+ * Returns a standard LZMA2 (.xz) encoder
+ *
+ * @param options preset or options
+ */
+ function createStream(coder: "easyEncoder", options?: number | I.lzma.EasyEncoderOptions): I.lzma.Stream;
+
+ /**
+ * Returns a standard LZMA 1/2 (bith .xz and .lzma) decoder with auto detection of file format
+ */
+ function createStream(coder: "autoDecoder", options?: I.lzma.AutoDecoderOptions): I.lzma.Stream;
+
+ /**
+ * Returns a standard LZMA encoder
+ *
+ * @param options preset or options
+ */
+ function createStream(coder: "aloneEncoder", options?: number | I.lzma.AloneEncoderOptions): I.lzma.Stream;
+
+ /**
+ * Returns a standard LZMA decoder
+ */
+ function createStream(coder: "aloneDecoder", options?: I.lzma.AloneDecoderOptions): I.lzma.Stream;
+
+ /**
+ * Returns a custom encoder corresponding to lzma_raw_encoder
+ */
+ function createStream(coder: "rawEncoder", options?: I.lzma.RawEncoderOptions): I.lzma.Stream;
+
+ /**
+ * Returns a custom decoder corresponding to lzma_raw_decoder
+ */
+ function createStream(coder: "rawDecoder", options?: I.lzma.RawDecoderOptions): I.lzma.Stream;
+
+ /**
+ * Returns a custom encoder corresponding to lzma_stream_encoder
+ */
+ function createStream(coder: "streamEncoder", options?: I.lzma.StreamEncoderOptions): I.lzma.Stream;
+
+ /**
+ * Returns a custom decoder corresponding to lzma_stream_decoder
+ */
+ function createStream(coder: "streamDecoder", options?: I.lzma.StreamDecoderOptions): I.lzma.Stream;
+
+ /**
+ * Encodes the given string or buffer using the given stream
+ */
+ function singleStringCoding(
+ stream: I.lzma.Stream,
+ string: string | Buffer,
+ onFinish?: (err: any, data: Buffer) => void,
+ onProgress?: (progress: number) => void
+ ): Promise;
+
+ const CHECK_CRC32: number;
+ const CHECK_CRC64: number;
+ const CHECK_NONE: number;
+ const CHECK_SHA256: number;
+
+ const FILTERS_MAX: string;
+ const FILTER_ARM: string;
+ const FILTER_ARMTHUMB: string;
+ const FILTER_IA64: string;
+ const FILTER_POWERPC: string;
+ const FILTER_SPARC: string;
+ const FILTER_X86: string;
+ const FILTER_DELTA: string;
+ const FILTER_LZMA1: string;
+ const FILTER_LZMA2: string;
+
+ const PRESET_EXTREME: number;
+ const PRESET_DEFAULT: number;
+ const PRESET_LEVEL_MASK: number;
+
+ const MF_HC3: number;
+ const MF_HC4: number;
+ const MF_BT2: number;
+ const MF_BT3: number;
+ const MF_BT4: number;
+
+ const LZMA_TELL_NO_CHECK: number;
+ const LZMA_TELL_UNSUPPORTED_CHECK: number;
+ const LZMA_TELL_ANY_CHECK: number;
+ const LZMA_CONCATENATED: number;
+
+ const MODE_FAST: number;
+ const MODE_NORMAL: number;
+
+ const STREAM_HEADER_SIZE: number;
+
+ /**
+ * Compresses the given string or buffer
+ *
+ * @param options preset or options
+ */
+ function compress(buf: string | Buffer, options?: number | I.lzma.EasyEncoderOptions): Promise;
+
+ /**
+ * Creates a compress stream
+ *
+ * @param options preset or options
+ */
+ function compressStream(options?: number | I.lzma.EasyEncoderOptions): I.lzma.Stream;
+
+ /**
+ * Decompresses the given buffer
+ */
+ function decompress(buf: Buffer, options?: I.lzma.AutoDecoderOptions): Promise;
+
+ /**
+ * Creates a decompress stream
+ *
+ * @param options preset or options
+ */
+ function decompressStream(options?: I.lzma.AutoDecoderOptions): I.lzma.Stream;
+ }
+ }
+}
diff --git a/types/adone/glosses/data.d.ts b/types/adone/glosses/data.d.ts
new file mode 100644
index 0000000000..f711836bdd
--- /dev/null
+++ b/types/adone/glosses/data.d.ts
@@ -0,0 +1,1032 @@
+declare namespace adone {
+ /**
+ * Various data [de]serializers
+ */
+ namespace data {
+ /**
+ * JSON encoder
+ */
+ namespace json {
+ namespace I {
+ type Replacer = ((key: string, value: any) => any) | string[];
+ interface CompareValue {
+ key: string;
+ value: any;
+ }
+ type CompareFunction = (a: CompareValue, b: CompareValue) => number;
+ }
+
+ /**
+ * Actually, the same as JSON.stringify, but returns a buffer
+ */
+ function encode(obj: any, options?: {
+ /**
+ * A String or Number object that's used to insert white space into the output JSON string for readability purposes
+ */
+ space?: string,
+
+ /**
+ * A function that alters the behavior of the stringification process,
+ * or an array of String and Number objects that serve as a whitelist
+ * for selecting/filtering the properties of the value object to be included in the JSON string
+ */
+ replacer?: I.Replacer
+ }): Buffer;
+
+ /**
+ * Decodes JSON string or buffer
+ */
+ function decode(buf: string | Buffer): any;
+
+ /**
+ * Deterministic version of JSON.stringify() so you can get a consistent hash from stringified results
+ */
+ function encodeStable(obj: any, options?: {
+ /**
+ * Indent spaces for pretty-printing
+ */
+ space?: string,
+
+ /**
+ * Whether to allow circular JSON structure
+ */
+ cycles?: boolean,
+
+ /**
+ * A function that alters the behavior of the stringification process,
+ * or an array of String and Number objects that serve as a whitelist
+ * for selecting/filtering the properties of the value object to be included in the JSON string
+ */
+ replacer?: I.Replacer,
+
+ /**
+ * Custom comparison function for object keys
+ */
+ cmp?: I.CompareFunction
+ }): string;
+
+ function encodeSafe(obj: any): string;
+
+ function decodeSafe(str: string): any;
+ }
+
+ /**
+ * MessagePack encoder
+ */
+ namespace mpak {
+ /**
+ * Encodes the given object
+ */
+ function encode(obj: any): Buffer;
+
+ /**
+ * Decoder the given buffer
+ */
+ function decode(buf: collection.I.ByteArray.Wrappable): any;
+
+ namespace I {
+ type Type = string | number; // ?
+ type DecodeFunction = (buf: collection.ByteArray) => any;
+ type EncodeFunction = (x: any) => collection.ByteArray;
+ type EncodeCheckFunction = (x: any) => boolean;
+
+ interface DecodingType {
+ /**
+ * Value type
+ */
+ type: Type;
+
+ /**
+ * Decode function
+ */
+ decode: DecodeFunction;
+ }
+
+ interface EncodingType {
+ /**
+ * Value type
+ */
+ type: Type;
+
+ /**
+ * Encode function
+ */
+ encode: EncodeFunction;
+
+ /**
+ * Check function
+ */
+ check: EncodeCheckFunction;
+ }
+ }
+
+ /**
+ * Represents a MessagePack encoder
+ */
+ class Encoder {
+ constructor(encodingTypes: I.EncodingType[]);
+
+ /**
+ * Encodes the given value
+ */
+ encode(x: any, buf?: T): T;
+ }
+
+ /**
+ * Represents a MessagePack decoder
+ */
+ class Decoder {
+ constructor(decodingTypes: I.DecodingType[]);
+
+ /**
+ * Decodes the given buffer
+ */
+ decode(buf: collection.I.ByteArray.Wrappable): any;
+
+ /**
+ * Decodes the given ByteArray buffer, but does not throw IncompleteBufferError if the size is invalid
+ */
+ tryDecode(buf: collection.ByteArray): any;
+ }
+
+ /**
+ * Represents a MessagePack serializer
+ */
+ class Serializer {
+ /**
+ * Encoder instance
+ */
+ readonly encoder: Encoder;
+
+ /**
+ * Decoder instance
+ */
+ readonly decoder: Decoder;
+
+ /**
+ * Registers an encoder for the given type
+ *
+ * @param type type identifier
+ * @param check type predicate
+ * @param encode type encoder
+ */
+ registerEncoder(type: I.Type, check: I.EncodeCheckFunction, encode: I.EncodeFunction): this;
+
+ /**
+ * Registers a decoder for the given type
+ *
+ * @param type type identifier
+ * @param decode type decoder
+ */
+ registerDecoder(type: I.Type, decode: I.DecodeFunction): this;
+
+ /**
+ * Registers encoder/decoder functions for the given type and constructor
+ *
+ * @param type type identifier
+ * @param constructor type constructor, used in the predicate function (instanceof)
+ * @param encode type encoder
+ * @param decode type decoder
+ */
+ register(
+ type: I.Type,
+ constructor: { new (...args: any[]): T },
+ encode: (x: T, buf: collection.ByteArray) => void,
+ decode: (buf: collection.ByteArray) => T
+ ): this;
+
+ /**
+ * Encodes the given value
+ */
+ encode(x: any, buf?: T): T;
+
+ /**
+ * Decodes the given buffer
+ */
+ decode(buf: collection.I.ByteArray.Wrappable, needFlip?: boolean): any;
+ }
+
+ /**
+ * An instance of default adone serializer with registered encoders/decoders for standard js/adone types like
+ * x.Exception, Error, Date, Map, Set, math.Long
+ */
+ const serializer: Serializer;
+ }
+
+ /**
+ * JSON5 encoder
+ */
+ namespace json5 {
+ /**
+ * Encodes the given value
+ */
+ function encode(obj: any, options?: {
+ /**
+ * Indent spaces for pretty-printing
+ */
+ space?: string,
+
+ /**
+ * A function that alters the behavior of the stringification process,
+ * or an array of String and Number objects that serve as a whitelist
+ * for selecting/filtering the properties of the value object to be included in the JSON string
+ */
+ replacer?: ((key: string, value: any) => any) | string[]
+ }): Buffer;
+
+ /**
+ * Decodes the given string/buffer
+ */
+ function decode(buf: string | Buffer, reviver?: (holder: object, key: string, value: any) => any): any;
+ }
+
+ /**
+ * Base64 encoder
+ */
+ namespace base64 {
+ /**
+ * Encodes a string/Buffer to base64
+ */
+ function encode(str: string | Buffer, options: { buffer: false }): string;
+ function encode(str: string | Buffer, options?: { buffer?: true }): Buffer;
+
+ /**
+ * Decodes base64 string/buffer into a buffer
+ */
+ function decode(str: string | Buffer, options: { buffer: true }): Buffer;
+
+ /**
+ * Decodes base64 string/buffer into a string
+ */
+ function decode(str: string | Buffer, options?: { buffer?: false }): string;
+
+ function encodeVLQ(value: number): string;
+
+ function decodeVLQ(value: string, index: number | undefined, rest: true): { value: number, index: number };
+ function decodeVLQ(value: string, index?: number, rest?: boolean): number;
+
+ /**
+ * Maps a character to a base64 number
+ */
+ function decodeCharCode(c: string): number;
+
+ /**
+ * Maps a number to a base64 character
+ */
+ function decodeNumber(n: number): string;
+ }
+
+ /**
+ * YAML encoder
+ */
+ namespace yaml {
+ /**
+ * YAML loaders
+ */
+ namespace loader {
+ namespace I {
+ interface Options {
+ /**
+ * String to be used as a file path in error/warning messages. Default: null
+ */
+ filename?: string;
+
+ /**
+ * Specifies a schema to use
+ */
+ schema?: schema.Schema;
+
+ /**
+ * Function to call on warning messages.
+ * Loader will throw on warnings if this function is not provided
+ */
+ onWarning?(warning: any): void;
+
+ /**
+ * Compatibility with JSON.parse behaviour.
+ * If true, then duplicate keys in a mapping will override values rather than throwing an error
+ */
+ json?: boolean;
+ }
+ }
+
+ /**
+ * Same as safeLoadAll() but uses DEFAULT_FULL by default
+ */
+ function loadAll(input: string | Buffer, iterator: (doc: any) => void, options?: I.Options): void;
+ function loadAll(input: string | Buffer, iterator?: undefined, options?: I.Options): any[];
+
+ /**
+ * The same as safeLoad() but uses DEFAULT_FULL_SCHEMA by default - adds some JavaScript-specific types: !!js/function, !!js/regexp and !!js/undefined.
+ * For untrusted sources, you must additionally validate object structure to avoid injections
+ */
+ function load(input: string | Buffer, options?: I.Options): any;
+
+ /**
+ * Parses string as single YAML document. Returns a JavaScript object or throws YAMLException on error.
+ * By default, does not support regexps, functions and undefined.
+ * This method is safe for untrusted data
+ */
+ function safeLoadAll(input: string | Buffer, iterator: (doc: any) => void, options?: I.Options): void;
+ function safeLoadAll(input: string | Buffer, iterator?: undefined, options?: I.Options): any[];
+
+ /**
+ * Same as safeLoad(), but understands multi-document sources.
+ * Applies iterator to each document if specified, or returns array of documents
+ */
+ function safeLoad(input: string | Buffer, options?: I.Options): any;
+ }
+
+ /**
+ * YAML dumpers
+ */
+ namespace dumper {
+ namespace I {
+ interface Options {
+ /**
+ * indentation width to use (in spaces). Default: 2
+ */
+ indent?: number;
+
+ /**
+ * Do not throw on invalid types (like function in the safe schema) and skip pairs and single values with such types.
+ * Default: false
+ */
+ skipInvalid?: boolean;
+
+ /**
+ * Specifies level of nesting, when to switch from block to flow style for collections.
+ * -1 means block style everwhere. Default: -1
+ */
+ flowLevel?: number;
+
+ /**
+ * "tag" => "style" map. Each tag may have own set of styles
+ */
+ styles?: object;
+
+ /**
+ * Specifies a schema to use
+ */
+ schema?: schema.Schema;
+
+ /**
+ * If true, sort keys when dumping YAML. If a function, use the function to sort the keys. Default: false
+ */
+ sortKeys?: boolean;
+
+ /**
+ * Set max line width. Default: 80
+ */
+ lineWidth?: number;
+
+ /**
+ * If true, don't convert duplicate objects into references. Default: false
+ */
+ noRefs?: boolean;
+
+ /**
+ * If true don't try to be compatible with older yaml versions.
+ * Currently: don't quote "yes", "no" and so on, as required for YAML 1.1.
+ * Default: false
+ */
+ noCompatMode?: boolean;
+
+ /**
+ * If true flow sequences will be condensed, omitting the space between a, b. Eg. '[a,b]'
+ */
+ condenseFlow?: boolean;
+ }
+ }
+
+ /**
+ * Same as safeDump() but without limits (uses DEFAULT_FULL by default)
+ */
+ function dump(input: any, options?: I.Options): string;
+
+ /**
+ * Serializes object as a YAML document.
+ * Uses DEFAULT_SAFE, so it will throw an exception if you try to dump regexps or functions
+ */
+ function safeDump(input: any, options?: I.Options): string;
+ }
+
+ /**
+ * YAML types for custom schemas
+ */
+ namespace type {
+ namespace I {
+ type Kind = "scalar" | "sequence" | "mapping";
+
+ interface TypeOptions {
+ kind: Kind;
+ resolve?(data: string): boolean;
+ construct?(data: string): T;
+ instanceOf?: object;
+ predicate?(obj: any): boolean;
+ represent?: ((obj: any, style: string) => string) | { [key: string]: (obj: any, style: string) => string };
+ defaultStyle?: string;
+ styleAliases?: object;
+ }
+ }
+
+ class Type {
+ tag: string;
+ resolve(data: string): boolean;
+ construct(data: string): T;
+ instanceOf?: object;
+ predicate?(obj: any): boolean;
+ represent?: (obj: any, style: string) => string | { [key: string]: (obj: any, style: string) => string };
+ defaultStyle?: string;
+ styleAliases?: object;
+
+ constructor(tag: string, options: I.TypeOptions);
+ }
+
+ namespace I {
+ interface Scalar extends Type {
+ kind: "scalar";
+ }
+
+ interface Mapping extends Type