@thewtex/vtk.js-esm
Version:
Visualization Toolkit for the Web
29 lines (26 loc) • 986 B
JavaScript
import { u as utils } from '../utils.js';
import { s as support } from '../support.js';
import { A as ArrayReader_1 } from './ArrayReader.js';
import { S as StringReader_1 } from './StringReader.js';
import { N as NodeBufferReader_1 } from './NodeBufferReader.js';
import { U as Uint8ArrayReader_1 } from './Uint8ArrayReader.js';
/**
* Create a reader adapted to the data.
* @param {String|ArrayBuffer|Uint8Array|Buffer} data the data to read.
* @return {DataReader} the data reader.
*/
var readerFor = function (data) {
var type = utils.getTypeOf(data);
utils.checkSupport(type);
if (type === "string" && !support.uint8array) {
return new StringReader_1(data);
}
if (type === "nodebuffer") {
return new NodeBufferReader_1(data);
}
if (support.uint8array) {
return new Uint8ArrayReader_1(utils.transformTo("uint8array", data));
}
return new ArrayReader_1(utils.transformTo("array", data));
};
export { readerFor as r };