UNPKG

gnablib

Version:

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

2 lines 595 B
/*! Copyright 2025 the gnablib contributors MPL-1.1 */ export class _AHashsum{constructor(s,t){this.size=s,this._bPos=0,this._b8=new Uint8Array(t)}get blockSize(){return this._b8.length}write(s){let t=s.length,e=0,h=this._b8.length-this._bPos;for(;t>0;){if(h>t)return this._b8.set(s.subarray(e),this._bPos),void(this._bPos+=t);this._b8.set(s.subarray(e,e+h),this._bPos),this.hash(),e+=h,t-=h,h=this._b8.length}}sum(){return this.clone().sumIn()}}export class AHashsum32 extends _AHashsum{constructor(){super(...arguments),this._ingestBytes=0}write(s){this._ingestBytes+=s.length,super.write(s)}}