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AE;QACP,GAAG;YAAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;gBAAE,OAAO,KAAK,CAAC;aAAE;SAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,EAAE;KAC/D;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAPD,4CAOC","file":"buffer.js","sourcesContent":["// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\n\nimport { flatbuffers } from 'flatbuffers';\nimport { encodeUtf8 } from '../util/utf8';\nimport ByteBuffer = flatbuffers.ByteBuffer;\nimport { TypedArray, TypedArrayConstructor } from '../interfaces';\nimport { BigIntArray, BigIntArrayConstructor } from '../interfaces';\nimport { isPromise, isIterable, isAsyncIterable, isIteratorResult, BigInt64Array, BigUint64Array } from './compat';\n\n/** @ignore */\nconst SharedArrayBuf = (typeof SharedArrayBuffer !== 'undefined' ? SharedArrayBuffer : ArrayBuffer);\n\n/** @ignore */\nfunction collapseContiguousByteRanges(chunks: Uint8Array[]) {\n let result = chunks[0] ? [chunks[0]] : [];\n let xOffset: number, yOffset: number, xLen: number, yLen: number;\n for (let x, y, i = 0, j = 0, n = chunks.length; ++i < n;) {\n x = result[j];\n y = chunks[i];\n // continue if x and y don't share the same underlying ArrayBuffer, or if x isn't before y\n if (!x || !y || x.buffer !== y.buffer || y.byteOffset < x.byteOffset) {\n y && (result[++j] = y);\n continue;\n }\n ({ byteOffset: xOffset, byteLength: xLen } = x);\n ({ byteOffset: yOffset, byteLength: yLen } = y);\n // continue if the byte ranges of x and y aren't contiguous\n if ((xOffset + xLen) < yOffset || (yOffset + yLen) < xOffset) {\n y && (result[++j] = y);\n continue;\n }\n result[j] = new Uint8Array(x.buffer, xOffset, yOffset - xOffset + yLen);\n }\n return result;\n}\n\n/** @ignore */\nexport function memcpy(target: TTarget, source: TSource, targetByteOffset = 0, sourceByteLength = source.byteLength) {\n const targetByteLength = target.byteLength;\n const dst = new Uint8Array(target.buffer, target.byteOffset, targetByteLength);\n const src = new Uint8Array(source.buffer, source.byteOffset, Math.min(sourceByteLength, targetByteLength));\n dst.set(src, targetByteOffset);\n return target;\n}\n\n/** @ignore */\nexport function joinUint8Arrays(chunks: Uint8Array[], size?: number | null): [Uint8Array, Uint8Array[], number] {\n // collapse chunks that share the same underlying ArrayBuffer and whose byte ranges overlap,\n // to avoid unnecessarily copying the bytes to do this buffer join. This is a common case during\n // streaming, where we may be reading partial byte ranges out of the same underlying ArrayBuffer\n let result = collapseContiguousByteRanges(chunks);\n let byteLength = result.reduce((x, b) => x + b.byteLength, 0);\n let source: Uint8Array, sliced: Uint8Array, buffer: Uint8Array | void;\n let offset = 0, index = -1, length = Math.min(size || Infinity, byteLength);\n for (let n = result.length; ++index < n;) {\n source = result[index];\n sliced = source.subarray(0, Math.min(source.length, length - offset));\n if (length <= (offset + sliced.length)) {\n if (sliced.length < source.length) {\n result[index] = source.subarray(sliced.length);\n } else if (sliced.length === source.length) { index++; }\n buffer ? memcpy(buffer, sliced, offset) : (buffer = sliced);\n break;\n }\n memcpy(buffer || (buffer = new Uint8Array(length)), sliced, offset);\n offset += sliced.length;\n }\n return [buffer || new Uint8Array(0), result.slice(index), byteLength - (buffer ? buffer.byteLength : 0)];\n}\n\n/** @ignore */\nexport type ArrayBufferViewInput = ArrayBufferView | ArrayBufferLike | ArrayBufferView | Iterable | ArrayLike | ByteBuffer | string | null | undefined |\n IteratorResult | ArrayLike | ByteBuffer | string | null | undefined> |\n ReadableStreamReadResult | ArrayLike | ByteBuffer | string | null | undefined> ;\n\n/** @ignore */\nexport function toArrayBufferView(ArrayBufferViewCtor: TypedArrayConstructor, input: ArrayBufferViewInput): T;\nexport function toArrayBufferView(ArrayBufferViewCtor: BigIntArrayConstructor, input: ArrayBufferViewInput): T;\nexport function toArrayBufferView(ArrayBufferViewCtor: any, input: ArrayBufferViewInput) {\n\n let value: any = isIteratorResult(input) ? input.value : input;\n\n if (value instanceof ArrayBufferViewCtor) {\n if (ArrayBufferViewCtor === Uint8Array) {\n // Node's `Buffer` class passes the `instanceof Uint8Array` check, but we need\n // a real Uint8Array, since Buffer#slice isn't the same as Uint8Array#slice :/\n return new ArrayBufferViewCtor(value.buffer, value.byteOffset, value.byteLength);\n }\n return value;\n }\n if (!value) { return new ArrayBufferViewCtor(0); }\n if (typeof value === 'string') { value = encodeUtf8(value); }\n if (value instanceof ArrayBuffer) { return new ArrayBufferViewCtor(value); }\n if (value instanceof SharedArrayBuf) { return new ArrayBufferViewCtor(value); }\n if (value instanceof ByteBuffer) { return toArrayBufferView(ArrayBufferViewCtor, value.bytes()); }\n return !ArrayBuffer.isView(value) ? ArrayBufferViewCtor.from(value) : value.byteLength <= 0 ? new ArrayBufferViewCtor(0)\n : new ArrayBufferViewCtor(value.buffer, value.byteOffset, value.byteLength / ArrayBufferViewCtor.BYTES_PER_ELEMENT);\n}\n\n/** @ignore */ export const toInt8Array = (input: ArrayBufferViewInput) => toArrayBufferView(Int8Array, input);\n/** @ignore */ export const toInt16Array = (input: ArrayBufferViewInput) => toArrayBufferView(Int16Array, input);\n/** @ignore */ export const toInt32Array = (input: ArrayBufferViewInput) => toArrayBufferView(Int32Array, input);\n/** @ignore */ export const toBigInt64Array = (input: ArrayBufferViewInput) => toArrayBufferView(BigInt64Array, input);\n/** @ignore */ export const toUint8Array = (input: ArrayBufferViewInput) => toArrayBufferView(Uint8Array, input);\n/** @ignore */ export const toUint16Array = (input: ArrayBufferViewInput) => toArrayBufferView(Uint16Array, input);\n/** @ignore */ export const toUint32Array = (input: ArrayBufferViewInput) => toArrayBufferView(Uint32Array, input);\n/** @ignore */ export const toBigUint64Array = (input: ArrayBufferViewInput) => toArrayBufferView(BigUint64Array, input);\n/** @ignore */ export const toFloat32Array = (input: ArrayBufferViewInput) => toArrayBufferView(Float32Array, input);\n/** @ignore */ export const toFloat64Array = (input: ArrayBufferViewInput) => toArrayBufferView(Float64Array, input);\n/** @ignore */ export const toUint8ClampedArray = (input: ArrayBufferViewInput) => toArrayBufferView(Uint8ClampedArray, input);\n\n/** @ignore */\ntype ArrayBufferViewIteratorInput = Iterable | ArrayBufferViewInput;\n\n/** @ignore */\nconst pump = | AsyncIterator>(iterator: T) => { iterator.next(); return iterator; };\n\n/** @ignore */\nexport function* toArrayBufferViewIterator(ArrayCtor: TypedArrayConstructor, source: ArrayBufferViewIteratorInput) {\n\n const wrap = function*(x: T) { yield x; };\n const buffers: Iterable =\n (typeof source === 'string') ? wrap(source)\n : (ArrayBuffer.isView(source)) ? wrap(source)\n : (source instanceof ArrayBuffer) ? wrap(source)\n : (source instanceof SharedArrayBuf) ? wrap(source)\n : !isIterable(source) ? wrap(source) : source;\n\n yield* pump((function* (it) {\n let r: IteratorResult = null;\n do {\n r = it.next(yield toArrayBufferView(ArrayCtor, r));\n } while (!r.done);\n })(buffers[Symbol.iterator]()));\n}\n\n/** @ignore */ export const toInt8ArrayIterator = (input: ArrayBufferViewIteratorInput) => toArrayBufferViewIterator(Int8Array, input);\n/** @ignore */ export const toInt16ArrayIterator = (input: ArrayBufferViewIteratorInput) => toArrayBufferViewIterator(Int16Array, input);\n/** @ignore */ export const toInt32ArrayIterator = (input: ArrayBufferViewIteratorInput) => toArrayBufferViewIterator(Int32Array, input);\n/** @ignore */ export const toUint8ArrayIterator = (input: ArrayBufferViewIteratorInput) => toArrayBufferViewIterator(Uint8Array, input);\n/** @ignore */ export const toUint16ArrayIterator = (input: ArrayBufferViewIteratorInput) => toArrayBufferViewIterator(Uint16Array, input);\n/** @ignore */ export const toUint32ArrayIterator = (input: ArrayBufferViewIteratorInput) => toArrayBufferViewIterator(Uint32Array, input);\n/** @ignore */ export const toFloat32ArrayIterator = (input: ArrayBufferViewIteratorInput) => toArrayBufferViewIterator(Float32Array, input);\n/** @ignore */ export const toFloat64ArrayIterator = (input: ArrayBufferViewIteratorInput) => toArrayBufferViewIterator(Float64Array, input);\n/** @ignore */ export const toUint8ClampedArrayIterator = (input: ArrayBufferViewIteratorInput) => toArrayBufferViewIterator(Uint8ClampedArray, input);\n\n/** @ignore */\ntype ArrayBufferViewAsyncIteratorInput = AsyncIterable | Iterable | PromiseLike | ArrayBufferViewInput;\n\n/** @ignore */\nexport async function* toArrayBufferViewAsyncIterator(ArrayCtor: TypedArrayConstructor, source: ArrayBufferViewAsyncIteratorInput): AsyncIterableIterator {\n\n // if a Promise, unwrap the Promise and iterate the resolved value\n if (isPromise(source)) {\n return yield* toArrayBufferViewAsyncIterator(ArrayCtor, await source);\n }\n\n const wrap = async function*(x: T) { yield await x; };\n const emit = async function* >(source: T) {\n yield* pump((function*(it: Iterator) {\n let r: IteratorResult = null;\n do {\n r = it.next(yield r && r.value);\n } while (!r.done);\n })(source[Symbol.iterator]()));\n };\n\n const buffers: AsyncIterable =\n (typeof source === 'string') ? wrap(source) // if string, wrap in an AsyncIterableIterator\n : (ArrayBuffer.isView(source)) ? wrap(source) // if TypedArray, wrap in an AsyncIterableIterator\n : (source instanceof ArrayBuffer) ? wrap(source) // if ArrayBuffer, wrap in an AsyncIterableIterator\n : (source instanceof SharedArrayBuf) ? wrap(source) // if SharedArrayBuffer, wrap in an AsyncIterableIterator\n : isIterable(source) ? emit(source) // If Iterable, wrap in an AsyncIterableIterator and compose the `next` values\n : !isAsyncIterable(source) ? wrap(source) // If not an AsyncIterable, treat as a sentinel and wrap in an AsyncIterableIterator\n : source; // otherwise if AsyncIterable, use it\n\n yield* pump((async function* (it) {\n let r: IteratorResult = null;\n do {\n r = await it.next(yield toArrayBufferView(ArrayCtor, r));\n } while (!r.done);\n })(buffers[Symbol.asyncIterator]()));\n}\n\n/** @ignore */ export const toInt8ArrayAsyncIterator = (input: ArrayBufferViewAsyncIteratorInput) => toArrayBufferViewAsyncIterator(Int8Array, input);\n/** @ignore */ export const toInt16ArrayAsyncIterator = (input: ArrayBufferViewAsyncIteratorInput) => toArrayBufferViewAsyncIterator(Int16Array, input);\n/** @ignore */ export const toInt32ArrayAsyncIterator = (input: ArrayBufferViewAsyncIteratorInput) => toArrayBufferViewAsyncIterator(Int32Array, input);\n/** @ignore */ export const toUint8ArrayAsyncIterator = (input: ArrayBufferViewAsyncIteratorInput) => toArrayBufferViewAsyncIterator(Uint8Array, input);\n/** @ignore */ export const toUint16ArrayAsyncIterator = (input: ArrayBufferViewAsyncIteratorInput) => toArrayBufferViewAsyncIterator(Uint16Array, input);\n/** @ignore */ export const toUint32ArrayAsyncIterator = (input: ArrayBufferViewAsyncIteratorInput) => toArrayBufferViewAsyncIterator(Uint32Array, input);\n/** @ignore */ export const toFloat32ArrayAsyncIterator = (input: ArrayBufferViewAsyncIteratorInput) => toArrayBufferViewAsyncIterator(Float32Array, input);\n/** @ignore */ export const toFloat64ArrayAsyncIterator = (input: ArrayBufferViewAsyncIteratorInput) => toArrayBufferViewAsyncIterator(Float64Array, input);\n/** @ignore */ export const toUint8ClampedArrayAsyncIterator = (input: ArrayBufferViewAsyncIteratorInput) => toArrayBufferViewAsyncIterator(Uint8ClampedArray, input);\n\n/** @ignore */\nexport function rebaseValueOffsets(offset: number, length: number, valueOffsets: Int32Array) {\n // If we have a non-zero offset, create a new offsets array with the values\n // shifted by the start offset, such that the new start offset is 0\n if (offset !== 0) {\n valueOffsets = valueOffsets.slice(0, length + 1);\n for (let i = -1; ++i <= length;) {\n valueOffsets[i] += offset;\n }\n }\n return valueOffsets;\n}\n\n/** @ignore */\nexport function compareArrayLike>(a: T, b: T) {\n let i = 0, n = a.length;\n if (n !== b.length) { return false; }\n if (n > 0) {\n do { if (a[i] !== b[i]) { return false; } } while (++i < n);\n }\n return true;\n}\n"]}