/** * Provides helper functions to manipulate `Uint8Array` byte slices that are not * included on the `Uint8Array` prototype. * * @module */ /** Returns the index of the first occurrence of the needle array in the source * array, or -1 if it is not present. * * A start index can be specified as the third argument that begins the search * at that given index. The start index defaults to the start of the array. * * The complexity of this function is O(source.lenth * needle.length). * * ```ts * import { indexOfNeedle } from "./mod.ts"; * const source = new Uint8Array([0, 1, 2, 1, 2, 1, 2, 3]); * const needle = new Uint8Array([1, 2]); * console.log(indexOfNeedle(source, needle)); // 1 * console.log(indexOfNeedle(source, needle, 2)); // 3 * ``` */ export declare function indexOfNeedle(source: Uint8Array, needle: Uint8Array, start?: number): number; /** Returns the index of the last occurrence of the needle array in the source * array, or -1 if it is not present. * * A start index can be specified as the third argument that begins the search * at that given index. The start index defaults to the end of the array. * * The complexity of this function is O(source.lenth * needle.length). * * ```ts * import { lastIndexOfNeedle } from "./mod.ts"; * const source = new Uint8Array([0, 1, 2, 1, 2, 1, 2, 3]); * const needle = new Uint8Array([1, 2]); * console.log(lastIndexOfNeedle(source, needle)); // 5 * console.log(lastIndexOfNeedle(source, needle, 4)); // 3 * ``` */ export declare function lastIndexOfNeedle(source: Uint8Array, needle: Uint8Array, start?: number): number; /** Returns true if the prefix array appears at the start of the source array, * false otherwise. * * The complexity of this function is O(prefix.length). * * ```ts * import { startsWith } from "./mod.ts"; * const source = new Uint8Array([0, 1, 2, 1, 2, 1, 2, 3]); * const prefix = new Uint8Array([0, 1, 2]); * console.log(startsWith(source, prefix)); // true * ``` */ export declare function startsWith(source: Uint8Array, prefix: Uint8Array): boolean; /** Returns true if the suffix array appears at the end of the source array, * false otherwise. * * The complexity of this function is O(suffix.length). * * ```ts * import { endsWith } from "./mod.ts"; * const source = new Uint8Array([0, 1, 2, 1, 2, 1, 2, 3]); * const suffix = new Uint8Array([1, 2, 3]); * console.log(endsWith(source, suffix)); // true * ``` */ export declare function endsWith(source: Uint8Array, suffix: Uint8Array): boolean; /** Returns a new Uint8Array composed of `count` repetitions of the `source` * array. * * If `count` is negative, a `RangeError` is thrown. * * ```ts * import { repeat } from "./mod.ts"; * const source = new Uint8Array([0, 1, 2]); * console.log(repeat(source, 3)); // [0, 1, 2, 0, 1, 2, 0, 1, 2] * console.log(repeat(source, 0)); // [] * console.log(repeat(source, -1)); // RangeError * ``` */ export declare function repeat(source: Uint8Array, count: number): Uint8Array; /** Concatenate the given arrays into a new Uint8Array. * * ```ts * import { concat } from "./mod.ts"; * const a = new Uint8Array([0, 1, 2]); * const b = new Uint8Array([3, 4, 5]); * console.log(concat(a, b)); // [0, 1, 2, 3, 4, 5] */ export declare function concat(...buf: Uint8Array[]): Uint8Array; /** Returns true if the source array contains the needle array, false otherwise. * * A start index can be specified as the third argument that begins the search * at that given index. The start index defaults to the beginning of the array. * * The complexity of this function is O(source.length * needle.length). * * ```ts * import { includesNeedle } from "./mod.ts"; * const source = new Uint8Array([0, 1, 2, 1, 2, 1, 2, 3]); * const needle = new Uint8Array([1, 2]); * console.log(includesNeedle(source, needle)); // true * console.log(includesNeedle(source, needle, 6)); // false * ``` */ export declare function includesNeedle(source: Uint8Array, needle: Uint8Array, start?: number): boolean; /** Copy bytes from the `src` array to the `dst` array. Returns the number of * bytes copied. * * If the `src` array is larger than what the `dst` array can hold, only the * amount of bytes that fit in the `dst` array are copied. * * An offset can be specified as the third argument that begins the copy at * that given index in the `dst` array. The offset defaults to the beginning of * the array. * * ```ts * import { copy } from "./mod.ts"; * const src = new Uint8Array([9, 8, 7]); * const dst = new Uint8Array([0, 1, 2, 3, 4, 5]); * console.log(copy(src, dst)); // 3 * console.log(dst); // [9, 8, 7, 3, 4, 5] * ``` * * ```ts * import { copy } from "./mod.ts"; * const src = new Uint8Array([1, 1, 1, 1]); * const dst = new Uint8Array([0, 0, 0, 0]); * console.log(copy(src, dst, 1)); // 3 * console.log(dst); // [0, 1, 1, 1] * ``` */ export declare function copy(src: Uint8Array, dst: Uint8Array, off?: number): number; export { equals } from "./equals.js";