import { VoidCallback, OneDeepNestedArray } from './common-types'; export declare const noop: () => any; export declare function prntprtty(val: any, indent?: number): string; /** * * @param s template-able string value. * ex: template ```var s = `${myvar}` ``` is equivalent to ```var t = makeTemplate("${myvar}"); s = eval(t)``` * sometimes it can be useful to define the form of a template without evaluating it, * but pass it to the component that will do that later and thus separate these two steps as shown above. * notice that the variables used in the prepared template can only relate to the scope(s) in which * the template effectively gets evaluated, not where it gets created with this function here. * if you want to evaluate values from one specific context to a string, but delegate the evaluation, use OOP or a closure. * @returns {string} value that can be passed to `eval` in order to be evaluated as a template. * */ export declare function makeTemplate(s: string): string; /** * * @returns true on finite values, false on Infinity * returns false on anything that is not convertible to a number (when not a number type), see isConvertibleToNumber */ export declare function isNumber(n: number): boolean; export declare function printNumberScaledAtDecimalOrder(value: number, order?: number): string; /** * * @returns true on: empty string, booleans, null, finite number values and +/- Infinity * false on: everything else -> objects, non-empty string, undefined, NaN (obviously) */ export declare function isConvertibleToNumber(n: any): boolean; export declare function isInteger(n: number): boolean; export declare function isIntegerIEEE754(n: number): boolean; /** * * @returns a finite number or +/- Infinity (if n was that value) * @throws error when value is not convertible to a number */ export declare function toNumber(n: any): number; export declare function flattenOneDeepNestedArray(a: OneDeepNestedArray): T[]; export declare function unsafeFlattenAnyNestedArray(array: any[]): T[]; export declare function lastOfArray(a: T[]): T | null; /** * Copies source data into a previously allocated destination buffer (see memcpy) */ export declare function copyArrayBuffer(src: ArrayBuffer, dest: ArrayBuffer, length?: number, srcOffset?: number, destOffset?: number): void; /** * Iterate over copyArrayBuffer with array of ArrayBuffer as input, offset on each pass is shifted so * that the buffers content are concatenated in the destination. If destination size is too low * `copyArrayBuffer` (i.e this function) will throw an error. * @param src * @param dest */ export declare function copyArrayBuffers(src: ArrayBuffer[], dest: ArrayBuffer): void; /** * Copies all data from one buffer into a new one, optionnally with offset and size arguments * @param buffer * @param offset * @param size */ export declare function copyToNewArrayBuffer(buffer: ArrayBuffer, offset?: number, size?: number): ArrayBuffer; export declare function copyArrayBufferCollection(abs: ArrayBuffer[]): ArrayBuffer[]; /** * Concatenates two existing buffers into a newly allocated third one * @param buffer1 * @param buffer2 */ export declare function concatArrayBuffers(buffer1: ArrayBuffer, buffer2: ArrayBuffer): ArrayBuffer; /** * Concatenate the data slices from two ArrayBufferView objects * @param typedArray1 * @param typedArray2 * @returns A new ArrayBuffer containing the concatenated data from both view windows in the specific order */ export declare function concatTypedArraySlice(typedArray1: ArrayBufferView, typedArray2: ArrayBufferView): ArrayBuffer; /** * Copies only the window that the view points to into a new buffer * @param typedArray * @returns A newly allocated ArrayBuffer */ export declare function copyTypedArraySlice(typedArray: ArrayBufferView): ArrayBuffer; export declare function writeTypedArraySlice(typedArray: ArrayBufferView, dest: ArrayBuffer, offset?: number): void; export declare function concatArrays(arg0: T[], ...args: T[][]): T[]; export declare function forEachOwnPropKeyInObject(object: Object, callback: (el: T) => void): void; export declare function dispatchAsyncTask(func: VoidCallback, timeoutSeconds?: number): number; export declare function cancelAsyncTask(id: number): void; export declare function parseOptionsFromQueryString(query?: string, validProperties?: string[]): { [property: string]: string; }; export declare function arrayBufferToHexdump(buffer: ArrayBuffer): string; export declare const utf8CharsToString: (bytes: Uint8Array) => string; export declare const unicodeCharsToString: (hexChars: Uint16Array) => string; export declare function utf8StringToBuffer(str: string): ArrayBuffer; /** * Copyright 2015 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ export declare function hexToBytes(s: string): Uint8Array; export declare function utf8decode(str: any): Uint8Array; export declare const MAX_UINT_32 = 4294967296; export declare const MAX_INT_32: number; export declare const MIN_INT_32: number; export declare const MAX_UINT_16 = 65536; export declare const readUint16: (buffer: Uint8Array, offset: number) => number; export declare const readUint32: (buffer: Uint8Array, offset: number) => number; export declare function writeUint32(buffer: Uint8Array, offset: number, value: number): number; export declare function writeInt32(data: Uint8Array, offset: number, value: number): number; export declare function decodeInt32(s: string): number; /** * * @param d * @param referenceDae defaults to midnight after Jan. 1, 1904 */ export declare function encodeDate(d: number, referenceDae?: number): number; export declare function encodeFloat_16_16(f: number): number; export declare function encodeFloat_2_30(f: number): number; export declare function encodeFloat_8_8(f: number): number; export declare function encodeLang(s: string): number; export declare const MAX_BITMASK_WIDTH = 31; export declare function bitMaskHasFlag(value: number, flag: number): boolean; export declare function bitMaskCombineFlags(value1: number, value2: number): number; export declare function bitMaskInvertFlags(value: number, enumSize?: number): number; export declare function bitMaskValueOfFlagEnum(order: number): number; export declare function bitMaskValueOfFlagEnumRange(from: number, to: number): number;