UNPKG

@dfinity/assets

Version:

JavaScript and TypeScript library to manage assets on the Internet Computer

23 lines 632 B
import mime from 'mime/lite.js'; export class ReadableBytes { constructor(fileName, bytes) { this.fileName = fileName; this._bytes = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes); } get contentType() { return mime.getType(this.fileName) ?? 'application/octet-stream'; } get length() { return this._bytes.byteLength; } async open() { return Promise.resolve(); } async close() { return Promise.resolve(); } async slice(start, end) { return this._bytes.slice(start, end); } } //# sourceMappingURL=readableBytes.js.map