UNPKG

gnablib

Version:

A lean, zero dependency library to provide a useful base for your project.

2 lines 603 B
/*! Copyright 2025 the gnablib contributors MPL-1.1 */ import{sInt as t}from"../safe/safe.js";import{AByteReader as e}from"./_AByteReader.js";const r=Symbol.for("nodejs.util.inspect.custom");export class ByteReader extends e{read(e){t("count",e).unsigned().atMost(this._buff.length-this._ptr).throwNot();const r=this._buff.slice(this._ptr,this._ptr+e);return this._ptr+=e,r}rest(){const t=this._buff.slice(this._ptr);return this._ptr=this._buff.length,t}get[Symbol.toStringTag](){return"ByteReader"}[r](){return`ByteReader([${this._buff.length}]@${this._ptr})`}static mount(t){return new ByteReader(t)}}