fs-slicer

1.0.7 • Public • Published

file-slice

Read chunk from file or join files from blocks tool.

Install

npm i fs-slicer --save

Example

const fileSlice = require("fs-slicer");
async function test() {
  const sourFilePath = "a.exe";
  const distFilePath = "./tmp/b.exe";
  const buffInfoArray = fileSlice.getSliceInfoArr(sourFilePath);
  console.log(buffInfoArray);
  const blockArr = [];
  for (const info of buffInfoArray) {
    const buf=await fileSlice.readOneBlock(sourFilePath, info);
    blockArr.push(buf);
  }
  await fileSlice.joinBlcoksToFile(distFilePath,blockArr);
}
test().then(()=>{});

APIs

    //get slice info but not real slice
    getSliceInfoArr(sourFilePath):Array[{start:number,end:number}];

    //read a block from file
    readOneBlock(sourFilePath, info):Promise<Buffer>;
    
    //join a file from blocks
    joinBlcoksToFile(distFilePath,blockArr):Promise<void>;
    

Package Sidebar

Install

npm i fs-slicer

Weekly Downloads

1

Version

1.0.7

License

MIT

Unpacked Size

4.9 kB

Total Files

5

Last publish

Collaborators

  • lanmeng2022