// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. import{typeBufReader}from"./buf_reader.ts";import{ readInt }from"./read_int.ts"; constMAX_SAFE_INTEGER=BigInt(Number.MAX_SAFE_INTEGER); /** * Read big endian 64bit long from BufReader * @param buf */exportasyncfunctionreadLong(buf:BufReader):Promise<number|null>{const high =awaitreadInt(buf);if(high ===null)returnnull;const low =awaitreadInt(buf);if(low ===null)thrownewDeno.errors.UnexpectedEof();const big =(BigInt(high)<<32n)|BigInt(low);// We probably should provide a similar API that returns BigInt values.if(big >MAX_SAFE_INTEGER){thrownewRangeError("Long value too big to be represented as a JavaScript number.",);}returnNumber(big);}