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E,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;SAChE;QACD,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IACM,KAAK,CAAC,KAAK,KAAK,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACpF,KAAK,CAAC,KAAK,CAAC,KAAW,IAAI,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAC9E,KAAK,CAAC,MAAM,CAAC,KAAW,IAAI,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;CACzF;AAvDD,sDAuDC","file":"file.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 { FileHandle } from './interfaces';\nimport { ByteStream, AsyncByteStream } from './stream';\nimport { ArrayBufferViewInput, toUint8Array } from '../util/buffer';\n\n/** @ignore */\nexport class RandomAccessFile extends ByteStream {\n public size: number;\n public position: number = 0;\n protected buffer: Uint8Array | null;\n constructor(buffer: ArrayBufferViewInput, byteLength?: number) {\n super();\n this.buffer = toUint8Array(buffer);\n this.size = typeof byteLength === 'undefined' ? this.buffer.byteLength : byteLength;\n }\n public readInt32(position: number) {\n const { buffer, byteOffset } = this.readAt(position, 4);\n return new DataView(buffer, byteOffset).getInt32(0, true);\n }\n public seek(position: number) {\n this.position = Math.min(position, this.size);\n return position < this.size;\n }\n public read(nBytes?: number | null) {\n const { buffer, size, position } = this;\n if (buffer && position < size) {\n if (typeof nBytes !== 'number') { nBytes = Infinity; }\n this.position = Math.min(size,\n position + Math.min(size - position, nBytes));\n return buffer.subarray(position, this.position);\n }\n return null;\n }\n public readAt(position: number, nBytes: number) {\n const buf = this.buffer;\n const end = Math.min(this.size, position + nBytes);\n return buf ? buf.subarray(position, end) : new Uint8Array(nBytes);\n }\n public close() { this.buffer && (this.buffer = null); }\n public throw(value?: any) { this.close(); return { done: true, value }; }\n public return(value?: any) { this.close(); return { done: true, value }; }\n}\n\n/** @ignore */\nexport class AsyncRandomAccessFile extends AsyncByteStream {\n // @ts-ignore\n public size: number;\n public position: number = 0;\n public _pending?: Promise<void>;\n protected _handle: FileHandle | null;\n constructor(file: FileHandle, byteLength?: number) {\n super();\n this._handle = file;\n if (typeof byteLength === 'number') {\n this.size = byteLength;\n } else {\n this._pending = (async () => {\n this.size = (await file.stat()).size;\n delete this._pending;\n })();\n }\n }\n public async readInt32(position: number) {\n const { buffer, byteOffset } = await this.readAt(position, 4);\n return new DataView(buffer, byteOffset).getInt32(0, true);\n }\n public async seek(position: number) {\n this._pending && await this._pending;\n this.position = Math.min(position, this.size);\n return position < this.size;\n }\n public async read(nBytes?: number | null) {\n this._pending && await this._pending;\n const { _handle: file, size, position } = this;\n if (file && position < size) {\n if (typeof nBytes !== 'number') { nBytes = Infinity; }\n let pos = position, offset = 0, bytesRead = 0;\n let end = Math.min(size, pos + Math.min(size - pos, nBytes));\n let buffer = new Uint8Array(Math.max(0, (this.position = end) - pos));\n while ((pos += bytesRead) < end && (offset += bytesRead) < buffer.byteLength) {\n ({ bytesRead } = await file.read(buffer, offset, buffer.byteLength - offset, pos));\n }\n return buffer;\n }\n return null;\n }\n public async readAt(position: number, nBytes: number) {\n this._pending && await this._pending;\n const { _handle: file, size } = this;\n if (file && (position + nBytes) < size) {\n const end = Math.min(size, position + nBytes);\n const buffer = new Uint8Array(end - position);\n return (await file.read(buffer, 0, nBytes, position)).buffer;\n }\n return new Uint8Array(nBytes);\n }\n public async close() { const f = this._handle; this._handle = null; f && await f.close(); }\n public async throw(value?: any) { await this.close(); return { done: true, value }; }\n public async return(value?: any) { await this.close(); return { done: true, value }; }\n}\n"]}