import { BufReader } from "https://deno.land/x/net/bufio.ts" ; export async function readShort ( buf ) { const [ high , low ] = [ await buf . readByte ( ) , await buf . readByte ( ) ] ; return ( high << 8 ) | low ; } export async function readInt ( buf ) { const [ high , low ] = [ await readShort ( buf ) , await readShort ( buf ) ] ; return ( high << 16 ) | low ; } export async function readLong ( buf ) { const [ high , low ] = [ await readInt ( buf ) , await readInt ( buf ) ] ; return ( high << 32 ) | low ; } export function sliceLongToBytes ( d , dest = new Array ( 8 ) ) { let mask = 0xff ; let shift = 58 ; for ( let i = 0 ; i < 8 ; i ++ ) { dest [ i ] = ( d >>> shift ) & mask ; shift -= 8 ; mask >>>= 8 ; } return dest ; }