js-cfb/bits/42_sectorify.js
SheetJS 5a769874f4 version bump 0.12.0: refresh
- pin dependencies
- flow and typescript improvements
- updated repo infrastructure
2017-07-28 13:53:08 -04:00

10 lines
345 B
JavaScript

/** Break the file up into sectors */
function sectorify(file/*:RawBytes*/, ssz/*:number*/)/*:Array<RawBytes>*/ {
var nsectors = Math.ceil(file.length/ssz)-1;
var sectors/*:Array<RawBytes>*/ = [];
for(var i=1; i < nsectors; ++i) sectors[i-1] = file.slice(i*ssz,(i+1)*ssz);
sectors[nsectors-1] = file.slice(nsectors*ssz);
return sectors;
}