/** Namespace that comprises various utils (also cleans up documentation). */ declare namespace auxiliaries { /** * Allows to specify the log verbosity. The default verbosity depends on the bundle type, e.g., a production bundle * might use a verbosity of 1, a local development bundle might favor a verbosity of 2. Even though verbosity levels * can be used arbitrarily, a verbosity of 0 is intended for user info only, 1 for developers, and 2 for developers * of this module. However, this semantic breaks when reusing this logging mechanism in other modules as well... * @param verbosity - Log level threshold, -1:disabled, 0:user, 1:developer, and 2:module developer. * @returns - The current log verbosity. */ function logVerbosity(verbosity?: number): number; /** * Log verbosity levels. */ enum LogLevel { Debug = 3, Info = 2, Warning = 1, Error = 0 } let assert: (statement: boolean, message: string) => void; /** * Allows to specify whether or not assertions should be enabled or disabled/ignored. * @param enable - If true, assertions will be evaluated and might throw errors. * @returns whether assertions are enabled */ function assertions(enable?: boolean): boolean; /** * Writes a warning to the console when the evaluated statement is false. * ``` * log(,`scale changed to ${scale}, given ${this._scale}`); * ``` * @param statement - Result of an statement expected to be true. * @param verbosity - Verbosity of log level: user, developer, or module developer. * @param message - Message to be passed to the log (if verbosity high enough). */ function log(verbosity: LogLevel, ...message: Array): void; /** * Writes a lo message to the console when the evaluated statement is false. * ``` * logIf(!vec2.equals(this._scale, scale), LogLevel.Info, `scale changed to ${scale}, given ${this._scale}`); * ``` * @param statement - Result of an statement expected to be true. * @param verbosity - Verbosity of log level: debug, info, warning, or error. * @param message - Message to be passed to the log (if thrown and verbosity high enough). */ function logIf(statement: boolean, verbosity: LogLevel, ...message: Array): void; /** * Starts performance measure using the performance API. This call initiates a performance mark and should be * followed by a `logPerformanceStop` call later on. Furthermore, the measurement can be tracked using, e.g., the * Chrome built-in performance profiler. Example: * ``` * gloperate.auxiliaries.logPerformanceStart('initialization'); * ... * gloperate.auxiliaries.logPerformanceStop('initialization'); * ``` * The example above should output something like: `[3] initialization | 5.635s`. * @param mark - Name for the performance measure and base name for the start mark (`-start`). */ function logPerformanceStart(mark: string): void; /** * Invokes `logPerformanceStart` iff the statement resolves successfully. * @param statement - Result of an statement expected to be true in order to invoke logPerformanceStart. * @param mark - Name for the performance measure mark ... @see {@link logPerformanceStart}. */ function logPerformanceStartIf(statement: boolean, mark: string): void; /** * This creates a second, end mark for the given mark name, then creates a performance measure between the start * and end mark (`-start` and `-end`), resolves the duration for logging and, finally, removes/cleans * both marks and the measure. The duration is pretty printed ranging from nanoseconds to seconds. Example: * ``` * gloperate.auxiliaries.logPerformanceStart('initialization'); * ... * gloperate.auxiliaries.logPerformanceStop('initialization', '#items processed: ' + items.length , 48); * ``` * The example above should output something like: `[3] initialization #items processed: 4096 | 7.172ms`. * @param mark - Name for the performance measure and base name for the end mark (`-end`). * @param message - Optional message to provide to the debug-log output. * @param measureIndent - Optional indentation of the measure (useful if multiple measurements shall be aligned). */ function logPerformanceStop(mark: string, message: string | undefined, measureIndent?: number): void; /** * Invokes `logPerformanceStop` under the condition that the statement is true. * @param statement - Result of an expression expected to be true in order to invoke logPerformanceStop. * @param mark - Name for the performance measure mark ... @see {@link logPerformanceStart}. * @param message - Optional message to provide to the debug-log output ... @see {@link logPerformanceStart}. * @param measureIndent - Optional indentation of the measure ... @see {@link logPerformanceStart}. */ function logPerformanceStopIf(statement: boolean, mark: string, message: string | undefined, measureIndent?: number): void; /** * Generates a random value within a given range [min,max]. * @param min - Minimum random value possible. * @param max - Maximum random value possible. * @returns - Random number in the range [min,max]. */ function rand(min?: number, max?: number): number; /** * Tests with binary operations if the number is power of two. * @param x The number to test. */ function isPowerOfTwo(x: number): boolean; /** * Computes the next upper power of two for the given number. Math is based on * {@link https://graphics.stanford.edu/~seander/bithacks.html}. * @param x - Number to compute next upper power of two for. */ function upperPowerOfTwo(x: number): number; /** * Prints bytes using ISO/IEC 80000 postfixes for bytes and fixed number of decimal places (3 decimal places if * bytes >= KiB). * ``` * prettyPrintBytes(27738900); // returns '26.454MiB' * ``` * @param bytes - Number of bytes in plain bytes. */ function prettyPrintBytes(bytes: number): string; /** * Prints given milliseconds in an appropriate seconds-based time unit and fixed number of decimal places. * ``` * prettyPrintMilliseconds(0.03277); // returns '32.770μs' * ``` * @param milliseconds - Number of milliseconds as floating point number. */ function prettyPrintMilliseconds(milliseconds: number): string; /** * Tests if specific bits are set in a given bitfield and returns true if so, false otherwise. */ function bitInBitfield(flags: GLbitfield, flag: GLbitfield | undefined): boolean; /** * Conversion multiplier for radians to degrees conversion (180 / PI). */ const RAD2DEG = 57.29577951308232; /** * Conversion multiplier for degrees to radians conversion (PI / 180). */ const DEG2RAD = 0.017453292519943295; /** * Queries window.location.search, or, if not present, window.location.search of the window's top frame. */ function GETsearch(): string; /** * Queries the value of a GET parameter. * @param parameter - Name/identifier of the parameter to query for. */ function GETparameter(parameter: string): string | undefined; /** * Path separator used for path related functions such as dirname and basename. */ const PATH_SEPARATOR = "/"; /** * Returns the directory name of a given (file) path. If no path separator is found, an empty dir name is returned. * @param path - Path string the directory name should be returned of. */ function dirname(path: string): string; /** * Returns the base name of a given file path. If no path separator is found, the input path is returned. * @param path - Path string the file/base name should be returned of. */ function basename(path: string): string; } export = auxiliaries;