refactor: remove unneeded for loop
Signed-off-by: Andrew Calcutt <acalcutt@techidiots.net>
This commit is contained in:
parent
a346462ae8
commit
79b9ebdc08
1 changed files with 3 additions and 12 deletions
|
|
@ -10,18 +10,9 @@ const PMTilesLocalSource = class {
|
|||
}
|
||||
async getBytes(offset, length) {
|
||||
const sharedBuffer = Buffer.alloc(length);
|
||||
const fd = fs.openSync(this.file); // file descriptor
|
||||
let bytesRead = 0; // how many bytes were read
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
let postion = offset + i;
|
||||
await ReadBytes(fd, sharedBuffer, postion);
|
||||
bytesRead = (i + 1) * length;
|
||||
if (bytesRead === length) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
fs.closeSync(fd); //close file when finished
|
||||
const fd = fs.openSync(this.file, 'r'); // file descriptor
|
||||
await ReadBytes(fd, sharedBuffer, offset);
|
||||
fs.closeSync(fd); //close file descriptor when finished
|
||||
return { data: BufferToArrayBuffer(sharedBuffer) };
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue