openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 684 B
JavaScript
import e from"node:fs";const t=2147483647;function validateWindow(e,t){if(!Number.isSafeInteger(t)||t<0||!Number.isSafeInteger(t+e.length))throw RangeError(`read position and window end must be non-negative safe integers`)}async function readFileWindowFully(e,n,r,{signal:i}={}){validateWindow(n,r),i?.throwIfAborted();let a=0;for(;a<n.length;){let{bytesRead:o}=await e.read(n,a,Math.min(n.length-a,t),r+a);if(i?.throwIfAborted(),o===0)break;a+=o}return a}function readFileWindowFullySync(n,r,i){validateWindow(r,i);let a=0;for(;a<r.length;){let o=e.readSync(n,r,a,Math.min(r.length-a,t),i+a);if(o===0)break;a+=o}return a}export{readFileWindowFullySync as n,readFileWindowFully as t};