chore: formatting

Signed-off-by: Andrew Calcutt <acalcutt@techidiots.net>
This commit is contained in:
Andrew Calcutt 2023-10-09 14:34:23 -04:00
parent 79b9ebdc08
commit 98995ab1be

View file

@ -9,17 +9,17 @@ const PMTilesLocalSource = class {
return this.file.name; return this.file.name;
} }
async getBytes(offset, length) { async getBytes(offset, length) {
const sharedBuffer = Buffer.alloc(length); const buffer = Buffer.alloc(length);
const fd = fs.openSync(this.file, 'r'); // file descriptor const fd = fs.openSync(this.file, 'r'); //Open the file in read mode
await ReadBytes(fd, sharedBuffer, offset); await ReadBytes(fd, buffer, offset); //Read the specifed bytes from the file
fs.closeSync(fd); //close file descriptor when finished fs.closeSync(fd); //close the file
return { data: BufferToArrayBuffer(sharedBuffer) }; return { data: BufferToArrayBuffer(buffer) };
} }
}; };
const ReadBytes = async (fd, sharedBuffer, offset) => { const ReadBytes = async (fd, buffer, offset) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
fs.read(fd, sharedBuffer, 0, sharedBuffer.length, offset, (err) => { fs.read(fd, buffer, 0, buffer.length, offset, (err) => {
if (err) { if (err) {
return reject(err); return reject(err);
} }