概述追加与区间覆盖可提高更新效率。本文提供最小用法。追加与覆盖async function appendText() {

const handle = await window.showSaveFilePicker({ suggestedName: 'log.txt' });

const ws = await handle.createWritable({ keepExistingData: true });

const file = await handle.getFile();

await ws.seek(file.size);

await ws.write(new Blob(['\nappend line'], { type: 'text/plain' }));

await ws.close();

}

async function coverRange(pos, bytes) {

const handle = await window.showSaveFilePicker({ suggestedName: 'data.bin' });

const ws = await handle.createWritable({ keepExistingData: true });

await ws.write({ type: 'write', position: pos, data: bytes });

await ws.close();

}

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部