@apr144/generic-filehandle
Version:
uniform interface for accessing binary data from local files, remote HTTP resources, and browser Blob data
21 lines • 702 B
JavaScript
import LocalFile from './localFile';
import RemoteFile from './remoteFile';
import BlobFile from './blobFile';
export * from './filehandle';
function fromUrl(source, opts = {}) {
return new RemoteFile(source, opts);
}
function open(maybeUrl, maybePath, maybeFilehandle, opts = {}) {
if (maybeFilehandle !== undefined) {
return maybeFilehandle;
}
if (maybeUrl !== undefined) {
return fromUrl(maybeUrl, opts);
}
if (maybePath !== undefined) {
return new LocalFile(maybePath, opts);
}
throw new Error('no url, path, or filehandle provided, cannot open');
}
export { open, fromUrl, RemoteFile, LocalFile, BlobFile };
//# sourceMappingURL=index.js.map