UNPKG

@loom-io/node-filesystem-adapter

Version:

A file system wrapper for Node.js and Bun

15 lines (14 loc) 525 B
export class FileHandler { openedFile; constructor(openedFile) { this.openedFile = openedFile; } async read(bufferOrOptions, _options = {}) { const [buffer, options] = bufferOrOptions instanceof Buffer ? [bufferOrOptions, _options] : [Buffer.alloc(16384), bufferOrOptions]; const { offset = 0, length = buffer.length - offset, position = 0 } = options; return this.openedFile.read(buffer, offset, length, position); } close() { this.openedFile.close(); } }