UNPKG

netcdf4-wasm

Version:

NetCDF4 library compiled to WebAssembly with TypeScript bindings

29 lines 1.08 kB
"use strict"; // Lazy file reading - reader factory // // Picks the right LazyReader backend for a given source: a Blob/File in the // browser, a path string in Node, or an already-constructed LazyReader passed // through unchanged. Object.defineProperty(exports, "__esModule", { value: true }); exports.createLazyReader = createLazyReader; const blob_reader_1 = require("./blob-reader"); const node_reader_1 = require("./node-reader"); function isLazyReader(value) { return (typeof value === "object" && value !== null && typeof value.read === "function" && typeof value.size === "number"); } function createLazyReader(source) { if (isLazyReader(source)) { return source; } if (typeof Blob !== "undefined" && source instanceof Blob) { return new blob_reader_1.BlobReader(source); } if (typeof source === "string") { return new node_reader_1.NodeFileReader(source); } throw new Error("Unsupported lazy source: expected a LazyReader, Blob, or file path string"); } //# sourceMappingURL=factory.js.map