{"version":3,"file":"eln-plugin.min.js","sources":["../src/types/default.js","../src/types/reaction/general.js","../node_modules/utf8/utf8.js","../node_modules/iobuffer/lib-esm/IOBuffer.js","../node_modules/netcdfjs/src/utils.js","../node_modules/netcdfjs/src/types.js","../node_modules/netcdfjs/src/data.js","../node_modules/netcdfjs/src/header.js","../node_modules/netcdfjs/src/toString.js","../node_modules/netcdfjs/src/index.js","../node_modules/netcdf-gcms/src/agilentGCMS.js","../node_modules/netcdf-gcms/src/brukerGCMS.js","../node_modules/netcdf-gcms/src/agilentHPLC.js","../node_modules/netcdf-gcms/src/finniganGCMS.js","../node_modules/netcdf-gcms/src/shimadzuGCMS.js","../node_modules/netcdf-gcms/src/advionGCMS.js","../node_modules/netcdf-gcms/src/aiaTemplate.js","../node_modules/netcdf-gcms/src/index.js","../node_modules/base64-js/index.js","../node_modules/atob/browser-atob.js","../node_modules/jcampconverter/src/complexChromatogram.js","../node_modules/jcampconverter/src/convertToFloatArray.js","../node_modules/jcampconverter/src/parse/fastParseXYData.js","../node_modules/jcampconverter/src/parse/parsePeakTable.js","../node_modules/jcampconverter/src/parse/parseXYA.js","../node_modules/is-any-array/src/index.js","../node_modules/median-quickselect/lib/median-quickselect.min.js","../node_modules/ml-array-median/lib-es6/index.js","../node_modules/jcampconverter/src/2d/add2D.js","../node_modules/jcampconverter/src/2d/convertTo3DZ.js","../node_modules/jcampconverter/src/2d/generateContourLines.js","../node_modules/nmr-processing/src/constants/impurities.js","../node_modules/nmr-processing/src/peaks/peaksFilterImpurities.js","../node_modules/ml-peak-shape-generator/src/util/constants.js","../node_modules/ml-peak-shape-generator/src/util/erfinv.js","../node_modules/ml-peak-shape-generator/src/classes/Gaussian.js","../node_modules/ml-peak-shape-generator/src/classes/Lorentzian.js","../node_modules/ml-peak-shape-generator/src/classes/PseudoVoigt.js","../node_modules/ml-peak-shape-generator/src/classes/Gaussian2D.js","../node_modules/ml-savitzky-golay-generalized/src/index.js","../node_modules/ml-gsd/src/gsd.js","../node_modules/ml-peak-shape-generator/src/util/getShapeGenerator.js","../node_modules/assign-symbols/index.js","../node_modules/assign-deep/index.js","../node_modules/ml-array-max/lib-es6/index.js","../node_modules/ml-spectra-fitting/src/shapes/sumOfGaussianLorentzians.js","../node_modules/ml-spectra-fitting/src/shapes/sumOfGaussians.js","../node_modules/ml-spectra-fitting/src/shapes/sumOfLorentzians.js","../node_modules/ml-levenberg-marquardt/src/errorCalculation.js","../node_modules/ml-array-min/lib-es6/index.js","../node_modules/ml-array-rescale/lib-es6/index.js","../node_modules/ml-matrix/src/inspect.js","../node_modules/ml-matrix/src/util.js","../node_modules/ml-matrix/src/matrix.js","../node_modules/ml-matrix/src/stat.js","../node_modules/ml-matrix/src/mathOperations.js","../node_modules/ml-matrix/src/wrap/WrapperMatrix2D.js","../node_modules/ml-matrix/src/dc/lu.js","../node_modules/ml-matrix/src/dc/util.js","../node_modules/ml-matrix/src/dc/qr.js","../node_modules/ml-matrix/src/dc/svd.js","../node_modules/ml-matrix/src/decompositions.js","../node_modules/ml-levenberg-marquardt/src/step.js","../node_modules/ml-levenberg-marquardt/src/gradientFunction.js","../node_modules/ml-levenberg-marquardt/src/index.js","../node_modules/ml-levenberg-marquardt/src/checkOptions.js","../node_modules/ml-spectra-fitting/src/selectMethod.js","../node_modules/ml-spectra-fitting/src/index.js","../node_modules/ml-spectra-fitting/src/checkInput.js","../node_modules/ml-spectra-processing/src/x/xFindClosestIndex.js","../node_modules/ml-spectra-processing/src/x/xGetFromToIndex.js","../node_modules/ml-array-sequential-fill/lib-es6/index.js","../node_modules/d3-array/build/d3-array.js","../node_modules/spline-interpolator/index.js","../node_modules/ml-spectra-processing/src/x/erfcinv.js","../node_modules/ml-spectra-processing/src/x/rayleighCdf.js","../node_modules/ml-spectra-processing/src/x/xNoiseSanPlot.js","../node_modules/ml-spectra-processing/src/xy/xyCheck.js","../node_modules/ml-spectra-processing/src/xy/xyExtract.js","../node_modules/ml-spectra-processing/src/zones/zonesNormalize.js","../node_modules/ml-spectra-processing/src/xy/xyIntegration.js","../node_modules/ml-gsd/src/post/optimizePeaks.js","../node_modules/ml-gsd/src/post/groupPeaks.js","../node_modules/ml-gsd/src/post/joinBroadPeaks.js","../node_modules/nmr-processing/src/xy/xyAutoPeaksPicking.js","../node_modules/ml-spectra-processing/src/x/xAbsoluteMedian.js","../node_modules/ml-spectra-processing/src/x/xAbsolute.js","../node_modules/nmr-processing/src/peaks/util/jAnalyzer.js","../node_modules/nmr-processing/src/peaks/peaksToRanges.js","../node_modules/nmr-processing/src/peaks/util/joinRanges.js","../node_modules/nmr-processing/src/xy/xyAutoRangesPicking.js","../node_modules/nmr-processing/src/constants/gyromagneticRatio.js","../node_modules/jcampconverter/src/profiling.js","../node_modules/jcampconverter/src/simpleChromatogram.js","../node_modules/jcampconverter/src/postProcessing.js","../node_modules/jcampconverter/src/postProcessingNMR.js","../node_modules/jcampconverter/src/prepareNtuplesDatatable.js","../node_modules/jcampconverter/src/prepareSpectrum.js","../node_modules/jcampconverter/src/convert.js","../node_modules/ensure-string/src/index.js","../src/types/common.js","../src/types/sample/chromatogram.js","../src/types/sample/cyclicVoltammetry.js","../src/types/sample/differentialCentrifugalSedimentation.js","../src/types/sample/differentialScanningCalorimetry.js","../src/types/sample/elementAnalysis.js","../node_modules/genbank-parser/src/utils/months.js","../node_modules/genbank-parser/src/index.js","../src/types/sample/genbank.js","../src/types/sample/general.js","../src/types/sample/hgPorosimetry.js","../src/types/sample/image.js","../src/types/sample/ir.js","../src/types/sample/isotherm.js","../src/types/sample/iv.js","../src/types/sample/mass.js","../node_modules/nmr-metadata/src/getMetaData.js","../node_modules/nmr-metadata/src/getNucleusFrom2DExperiment.js","../node_modules/nmr-metadata/src/getSpectrumType.js","../node_modules/nmr-metadata/src/index.js","../src/types/sample/nmr.js","../src/types/sample/oan.js","../src/types/sample/pelletHardness.js","../src/types/sample/physical.js","../src/types/sample/raman.js","../src/types/sample/thermogravimetricAnalysis.js","../src/types/sample/uv.js","../src/types/sample/video.js","../src/types/sample/xps.js","../src/types/sample/xray.js","../src/types/sample/xrd.js","../src/types/sample/xrf.js","../src/types/index.js","../src/types.js","../src/util/defaults.js","../src/index.js"],"sourcesContent":["export default {\n process() {\n return {};\n },\n\n getEmpty() {\n return [];\n },\n};\n","export default {\n jpath: [],\n getEmpty() {\n return {\n code: '',\n date: Date.now(),\n procedure: '',\n products: [],\n reagents: [],\n conditions: '',\n keywords: [],\n remarks: '',\n title: '',\n reactionRXN: '$RXN\\n\\n\\n\\n 0 0\\n',\n };\n },\n};\n","/*! https://mths.be/utf8js v3.0.0 by @mathias */\n;(function(root) {\n\n\tvar stringFromCharCode = String.fromCharCode;\n\n\t// Taken from https://mths.be/punycode\n\tfunction ucs2decode(string) {\n\t\tvar output = [];\n\t\tvar counter = 0;\n\t\tvar length = string.length;\n\t\tvar value;\n\t\tvar extra;\n\t\twhile (counter < length) {\n\t\t\tvalue = string.charCodeAt(counter++);\n\t\t\tif (value >= 0xD800 && value <= 0xDBFF && counter < length) {\n\t\t\t\t// high surrogate, and there is a next character\n\t\t\t\textra = string.charCodeAt(counter++);\n\t\t\t\tif ((extra & 0xFC00) == 0xDC00) { // low surrogate\n\t\t\t\t\toutput.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);\n\t\t\t\t} else {\n\t\t\t\t\t// unmatched surrogate; only append this code unit, in case the next\n\t\t\t\t\t// code unit is the high surrogate of a surrogate pair\n\t\t\t\t\toutput.push(value);\n\t\t\t\t\tcounter--;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\toutput.push(value);\n\t\t\t}\n\t\t}\n\t\treturn output;\n\t}\n\n\t// Taken from https://mths.be/punycode\n\tfunction ucs2encode(array) {\n\t\tvar length = array.length;\n\t\tvar index = -1;\n\t\tvar value;\n\t\tvar output = '';\n\t\twhile (++index < length) {\n\t\t\tvalue = array[index];\n\t\t\tif (value > 0xFFFF) {\n\t\t\t\tvalue -= 0x10000;\n\t\t\t\toutput += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);\n\t\t\t\tvalue = 0xDC00 | value & 0x3FF;\n\t\t\t}\n\t\t\toutput += stringFromCharCode(value);\n\t\t}\n\t\treturn output;\n\t}\n\n\tfunction checkScalarValue(codePoint) {\n\t\tif (codePoint >= 0xD800 && codePoint <= 0xDFFF) {\n\t\t\tthrow Error(\n\t\t\t\t'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +\n\t\t\t\t' is not a scalar value'\n\t\t\t);\n\t\t}\n\t}\n\t/*--------------------------------------------------------------------------*/\n\n\tfunction createByte(codePoint, shift) {\n\t\treturn stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);\n\t}\n\n\tfunction encodeCodePoint(codePoint) {\n\t\tif ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence\n\t\t\treturn stringFromCharCode(codePoint);\n\t\t}\n\t\tvar symbol = '';\n\t\tif ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence\n\t\t\tsymbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);\n\t\t}\n\t\telse if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence\n\t\t\tcheckScalarValue(codePoint);\n\t\t\tsymbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);\n\t\t\tsymbol += createByte(codePoint, 6);\n\t\t}\n\t\telse if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence\n\t\t\tsymbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);\n\t\t\tsymbol += createByte(codePoint, 12);\n\t\t\tsymbol += createByte(codePoint, 6);\n\t\t}\n\t\tsymbol += stringFromCharCode((codePoint & 0x3F) | 0x80);\n\t\treturn symbol;\n\t}\n\n\tfunction utf8encode(string) {\n\t\tvar codePoints = ucs2decode(string);\n\t\tvar length = codePoints.length;\n\t\tvar index = -1;\n\t\tvar codePoint;\n\t\tvar byteString = '';\n\t\twhile (++index < length) {\n\t\t\tcodePoint = codePoints[index];\n\t\t\tbyteString += encodeCodePoint(codePoint);\n\t\t}\n\t\treturn byteString;\n\t}\n\n\t/*--------------------------------------------------------------------------*/\n\n\tfunction readContinuationByte() {\n\t\tif (byteIndex >= byteCount) {\n\t\t\tthrow Error('Invalid byte index');\n\t\t}\n\n\t\tvar continuationByte = byteArray[byteIndex] & 0xFF;\n\t\tbyteIndex++;\n\n\t\tif ((continuationByte & 0xC0) == 0x80) {\n\t\t\treturn continuationByte & 0x3F;\n\t\t}\n\n\t\t// If we end up here, it’s not a continuation byte\n\t\tthrow Error('Invalid continuation byte');\n\t}\n\n\tfunction decodeSymbol() {\n\t\tvar byte1;\n\t\tvar byte2;\n\t\tvar byte3;\n\t\tvar byte4;\n\t\tvar codePoint;\n\n\t\tif (byteIndex > byteCount) {\n\t\t\tthrow Error('Invalid byte index');\n\t\t}\n\n\t\tif (byteIndex == byteCount) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Read first byte\n\t\tbyte1 = byteArray[byteIndex] & 0xFF;\n\t\tbyteIndex++;\n\n\t\t// 1-byte sequence (no continuation bytes)\n\t\tif ((byte1 & 0x80) == 0) {\n\t\t\treturn byte1;\n\t\t}\n\n\t\t// 2-byte sequence\n\t\tif ((byte1 & 0xE0) == 0xC0) {\n\t\t\tbyte2 = readContinuationByte();\n\t\t\tcodePoint = ((byte1 & 0x1F) << 6) | byte2;\n\t\t\tif (codePoint >= 0x80) {\n\t\t\t\treturn codePoint;\n\t\t\t} else {\n\t\t\t\tthrow Error('Invalid continuation byte');\n\t\t\t}\n\t\t}\n\n\t\t// 3-byte sequence (may include unpaired surrogates)\n\t\tif ((byte1 & 0xF0) == 0xE0) {\n\t\t\tbyte2 = readContinuationByte();\n\t\t\tbyte3 = readContinuationByte();\n\t\t\tcodePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;\n\t\t\tif (codePoint >= 0x0800) {\n\t\t\t\tcheckScalarValue(codePoint);\n\t\t\t\treturn codePoint;\n\t\t\t} else {\n\t\t\t\tthrow Error('Invalid continuation byte');\n\t\t\t}\n\t\t}\n\n\t\t// 4-byte sequence\n\t\tif ((byte1 & 0xF8) == 0xF0) {\n\t\t\tbyte2 = readContinuationByte();\n\t\t\tbyte3 = readContinuationByte();\n\t\t\tbyte4 = readContinuationByte();\n\t\t\tcodePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) |\n\t\t\t\t(byte3 << 0x06) | byte4;\n\t\t\tif (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {\n\t\t\t\treturn codePoint;\n\t\t\t}\n\t\t}\n\n\t\tthrow Error('Invalid UTF-8 detected');\n\t}\n\n\tvar byteArray;\n\tvar byteCount;\n\tvar byteIndex;\n\tfunction utf8decode(byteString) {\n\t\tbyteArray = ucs2decode(byteString);\n\t\tbyteCount = byteArray.length;\n\t\tbyteIndex = 0;\n\t\tvar codePoints = [];\n\t\tvar tmp;\n\t\twhile ((tmp = decodeSymbol()) !== false) {\n\t\t\tcodePoints.push(tmp);\n\t\t}\n\t\treturn ucs2encode(codePoints);\n\t}\n\n\t/*--------------------------------------------------------------------------*/\n\n\troot.version = '3.0.0';\n\troot.encode = utf8encode;\n\troot.decode = utf8decode;\n\n}(typeof exports === 'undefined' ? this.utf8 = {} : exports));\n","import { decode, encode } from 'utf8';\nconst defaultByteLength = 1024 * 8;\nexport class IOBuffer {\n /**\n * @param data - The data to construct the IOBuffer with.\n * If data is a number, it will be the new buffer's length
\n * If data is `undefined`, the buffer will be initialized with a default length of 8Kb
\n * If data is an ArrayBuffer, SharedArrayBuffer, an ArrayBufferView (Typed Array), an IOBuffer instance,\n * or a Node.js Buffer, a view will be created over the underlying ArrayBuffer.\n * @param options\n */\n constructor(data = defaultByteLength, options = {}) {\n let dataIsGiven = false;\n if (typeof data === 'number') {\n data = new ArrayBuffer(data);\n }\n else {\n dataIsGiven = true;\n this.lastWrittenByte = data.byteLength;\n }\n const offset = options.offset ? options.offset >>> 0 : 0;\n const byteLength = data.byteLength - offset;\n let dvOffset = offset;\n if (ArrayBuffer.isView(data) || data instanceof IOBuffer) {\n if (data.byteLength !== data.buffer.byteLength) {\n dvOffset = data.byteOffset + offset;\n }\n data = data.buffer;\n }\n if (dataIsGiven) {\n this.lastWrittenByte = byteLength;\n }\n else {\n this.lastWrittenByte = 0;\n }\n this.buffer = data;\n this.length = byteLength;\n this.byteLength = byteLength;\n this.byteOffset = dvOffset;\n this.offset = 0;\n this.littleEndian = true;\n this._data = new DataView(this.buffer, dvOffset, byteLength);\n this._mark = 0;\n this._marks = [];\n }\n /**\n * Checks if the memory allocated to the buffer is sufficient to store more\n * bytes after the offset.\n * @param byteLength - The needed memory in bytes.\n * @returns `true` if there is sufficient space and `false` otherwise.\n */\n available(byteLength = 1) {\n return this.offset + byteLength <= this.length;\n }\n /**\n * Check if little-endian mode is used for reading and writing multi-byte\n * values.\n * @returns `true` if little-endian mode is used, `false` otherwise.\n */\n isLittleEndian() {\n return this.littleEndian;\n }\n /**\n * Set little-endian mode for reading and writing multi-byte values.\n */\n setLittleEndian() {\n this.littleEndian = true;\n return this;\n }\n /**\n * Check if big-endian mode is used for reading and writing multi-byte values.\n * @returns `true` if big-endian mode is used, `false` otherwise.\n */\n isBigEndian() {\n return !this.littleEndian;\n }\n /**\n * Switches to big-endian mode for reading and writing multi-byte values.\n */\n setBigEndian() {\n this.littleEndian = false;\n return this;\n }\n /**\n * Move the pointer n bytes forward.\n * @param n - Number of bytes to skip.\n */\n skip(n = 1) {\n this.offset += n;\n return this;\n }\n /**\n * Move the pointer to the given offset.\n * @param offset\n */\n seek(offset) {\n this.offset = offset;\n return this;\n }\n /**\n * Store the current pointer offset.\n * @see {@link IOBuffer#reset}\n */\n mark() {\n this._mark = this.offset;\n return this;\n }\n /**\n * Move the pointer back to the last pointer offset set by mark.\n * @see {@link IOBuffer#mark}\n */\n reset() {\n this.offset = this._mark;\n return this;\n }\n /**\n * Push the current pointer offset to the mark stack.\n * @see {@link IOBuffer#popMark}\n */\n pushMark() {\n this._marks.push(this.offset);\n return this;\n }\n /**\n * Pop the last pointer offset from the mark stack, and set the current\n * pointer offset to the popped value.\n * @see {@link IOBuffer#pushMark}\n */\n popMark() {\n const offset = this._marks.pop();\n if (offset === undefined) {\n throw new Error('Mark stack empty');\n }\n this.seek(offset);\n return this;\n }\n /**\n * Move the pointer offset back to 0.\n */\n rewind() {\n this.offset = 0;\n return this;\n }\n /**\n * Make sure the buffer has sufficient memory to write a given byteLength at\n * the current pointer offset.\n * If the buffer's memory is insufficient, this method will create a new\n * buffer (a copy) with a length that is twice (byteLength + current offset).\n * @param byteLength\n */\n ensureAvailable(byteLength = 1) {\n if (!this.available(byteLength)) {\n const lengthNeeded = this.offset + byteLength;\n const newLength = lengthNeeded * 2;\n const newArray = new Uint8Array(newLength);\n newArray.set(new Uint8Array(this.buffer));\n this.buffer = newArray.buffer;\n this.length = this.byteLength = newLength;\n this._data = new DataView(this.buffer);\n }\n return this;\n }\n /**\n * Read a byte and return false if the byte's value is 0, or true otherwise.\n * Moves pointer forward by one byte.\n */\n readBoolean() {\n return this.readUint8() !== 0;\n }\n /**\n * Read a signed 8-bit integer and move pointer forward by 1 byte.\n */\n readInt8() {\n return this._data.getInt8(this.offset++);\n }\n /**\n * Read an unsigned 8-bit integer and move pointer forward by 1 byte.\n */\n readUint8() {\n return this._data.getUint8(this.offset++);\n }\n /**\n * Alias for {@link IOBuffer#readUint8}.\n */\n readByte() {\n return this.readUint8();\n }\n /**\n * Read `n` bytes and move pointer forward by `n` bytes.\n */\n readBytes(n = 1) {\n const bytes = new Uint8Array(n);\n for (let i = 0; i < n; i++) {\n bytes[i] = this.readByte();\n }\n return bytes;\n }\n /**\n * Read a 16-bit signed integer and move pointer forward by 2 bytes.\n */\n readInt16() {\n const value = this._data.getInt16(this.offset, this.littleEndian);\n this.offset += 2;\n return value;\n }\n /**\n * Read a 16-bit unsigned integer and move pointer forward by 2 bytes.\n */\n readUint16() {\n const value = this._data.getUint16(this.offset, this.littleEndian);\n this.offset += 2;\n return value;\n }\n /**\n * Read a 32-bit signed integer and move pointer forward by 4 bytes.\n */\n readInt32() {\n const value = this._data.getInt32(this.offset, this.littleEndian);\n this.offset += 4;\n return value;\n }\n /**\n * Read a 32-bit unsigned integer and move pointer forward by 4 bytes.\n */\n readUint32() {\n const value = this._data.getUint32(this.offset, this.littleEndian);\n this.offset += 4;\n return value;\n }\n /**\n * Read a 32-bit floating number and move pointer forward by 4 bytes.\n */\n readFloat32() {\n const value = this._data.getFloat32(this.offset, this.littleEndian);\n this.offset += 4;\n return value;\n }\n /**\n * Read a 64-bit floating number and move pointer forward by 8 bytes.\n */\n readFloat64() {\n const value = this._data.getFloat64(this.offset, this.littleEndian);\n this.offset += 8;\n return value;\n }\n /**\n * Read a 1-byte ASCII character and move pointer forward by 1 byte.\n */\n readChar() {\n return String.fromCharCode(this.readInt8());\n }\n /**\n * Read `n` 1-byte ASCII characters and move pointer forward by `n` bytes.\n */\n readChars(n = 1) {\n let result = '';\n for (let i = 0; i < n; i++) {\n result += this.readChar();\n }\n return result;\n }\n /**\n * Read the next `n` bytes, return a UTF-8 decoded string and move pointer\n * forward by `n` bytes.\n */\n readUtf8(n = 1) {\n const bString = this.readChars(n);\n return decode(bString);\n }\n /**\n * Write 0xff if the passed value is truthy, 0x00 otherwise and move pointer\n * forward by 1 byte.\n */\n writeBoolean(value) {\n this.writeUint8(value ? 0xff : 0x00);\n return this;\n }\n /**\n * Write `value` as an 8-bit signed integer and move pointer forward by 1 byte.\n */\n writeInt8(value) {\n this.ensureAvailable(1);\n this._data.setInt8(this.offset++, value);\n this._updateLastWrittenByte();\n return this;\n }\n /**\n * Write `value` as an 8-bit unsigned integer and move pointer forward by 1\n * byte.\n */\n writeUint8(value) {\n this.ensureAvailable(1);\n this._data.setUint8(this.offset++, value);\n this._updateLastWrittenByte();\n return this;\n }\n /**\n * An alias for {@link IOBuffer#writeUint8}.\n */\n writeByte(value) {\n return this.writeUint8(value);\n }\n /**\n * Write all elements of `bytes` as uint8 values and move pointer forward by\n * `bytes.length` bytes.\n */\n writeBytes(bytes) {\n this.ensureAvailable(bytes.length);\n for (let i = 0; i < bytes.length; i++) {\n this._data.setUint8(this.offset++, bytes[i]);\n }\n this._updateLastWrittenByte();\n return this;\n }\n /**\n * Write `value` as a 16-bit signed integer and move pointer forward by 2\n * bytes.\n */\n writeInt16(value) {\n this.ensureAvailable(2);\n this._data.setInt16(this.offset, value, this.littleEndian);\n this.offset += 2;\n this._updateLastWrittenByte();\n return this;\n }\n /**\n * Write `value` as a 16-bit unsigned integer and move pointer forward by 2\n * bytes.\n */\n writeUint16(value) {\n this.ensureAvailable(2);\n this._data.setUint16(this.offset, value, this.littleEndian);\n this.offset += 2;\n this._updateLastWrittenByte();\n return this;\n }\n /**\n * Write `value` as a 32-bit signed integer and move pointer forward by 4\n * bytes.\n */\n writeInt32(value) {\n this.ensureAvailable(4);\n this._data.setInt32(this.offset, value, this.littleEndian);\n this.offset += 4;\n this._updateLastWrittenByte();\n return this;\n }\n /**\n * Write `value` as a 32-bit unsigned integer and move pointer forward by 4\n * bytes.\n */\n writeUint32(value) {\n this.ensureAvailable(4);\n this._data.setUint32(this.offset, value, this.littleEndian);\n this.offset += 4;\n this._updateLastWrittenByte();\n return this;\n }\n /**\n * Write `value` as a 32-bit floating number and move pointer forward by 4\n * bytes.\n */\n writeFloat32(value) {\n this.ensureAvailable(4);\n this._data.setFloat32(this.offset, value, this.littleEndian);\n this.offset += 4;\n this._updateLastWrittenByte();\n return this;\n }\n /**\n * Write `value` as a 64-bit floating number and move pointer forward by 8\n * bytes.\n */\n writeFloat64(value) {\n this.ensureAvailable(8);\n this._data.setFloat64(this.offset, value, this.littleEndian);\n this.offset += 8;\n this._updateLastWrittenByte();\n return this;\n }\n /**\n * Write the charCode of `str`'s first character as an 8-bit unsigned integer\n * and move pointer forward by 1 byte.\n */\n writeChar(str) {\n return this.writeUint8(str.charCodeAt(0));\n }\n /**\n * Write the charCodes of all `str`'s characters as 8-bit unsigned integers\n * and move pointer forward by `str.length` bytes.\n */\n writeChars(str) {\n for (let i = 0; i < str.length; i++) {\n this.writeUint8(str.charCodeAt(i));\n }\n return this;\n }\n /**\n * UTF-8 encode and write `str` to the current pointer offset and move pointer\n * forward according to the encoded length.\n */\n writeUtf8(str) {\n const bString = encode(str);\n return this.writeChars(bString);\n }\n /**\n * Export a Uint8Array view of the internal buffer.\n * The view starts at the byte offset and its length\n * is calculated to stop at the last written byte or the original length.\n */\n toArray() {\n return new Uint8Array(this.buffer, this.byteOffset, this.lastWrittenByte);\n }\n /**\n * Update the last written byte offset\n * @private\n */\n _updateLastWrittenByte() {\n if (this.offset > this.lastWrittenByte) {\n this.lastWrittenByte = this.offset;\n }\n }\n}\n//# sourceMappingURL=IOBuffer.js.map","'use strict';\n\n/**\n * Throws a non-valid NetCDF exception if the statement it's true\n * @ignore\n * @param {boolean} statement - Throws if true\n * @param {string} reason - Reason to throw\n */\nfunction notNetcdf(statement, reason) {\n if (statement) {\n throw new TypeError(`Not a valid NetCDF v3.x file: ${reason}`);\n }\n}\n\n/**\n * Moves 1, 2, or 3 bytes to next 4-byte boundary\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n */\nfunction padding(buffer) {\n if ((buffer.offset % 4) !== 0) {\n buffer.skip(4 - (buffer.offset % 4));\n }\n}\n\n\n/**\n * Reads the name\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {string} - Name\n */\nfunction readName(buffer) {\n // Read name\n var nameLength = buffer.readUint32();\n var name = buffer.readChars(nameLength);\n\n // validate name\n // TODO\n\n // Apply padding\n padding(buffer);\n return name;\n}\n\nmodule.exports.notNetcdf = notNetcdf;\nmodule.exports.padding = padding;\nmodule.exports.readName = readName;\n","'use strict';\n\nconst notNetcdf = require('./utils').notNetcdf;\n\nconst types = {\n BYTE: 1,\n CHAR: 2,\n SHORT: 3,\n INT: 4,\n FLOAT: 5,\n DOUBLE: 6\n};\n\n/**\n * Parse a number into their respective type\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {string} - parsed value of the type\n */\nfunction num2str(type) {\n switch (Number(type)) {\n case types.BYTE:\n return 'byte';\n case types.CHAR:\n return 'char';\n case types.SHORT:\n return 'short';\n case types.INT:\n return 'int';\n case types.FLOAT:\n return 'float';\n case types.DOUBLE:\n return 'double';\n /* istanbul ignore next */\n default:\n return 'undefined';\n }\n}\n\n/**\n * Parse a number type identifier to his size in bytes\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {number} -size of the type\n */\nfunction num2bytes(type) {\n switch (Number(type)) {\n case types.BYTE:\n return 1;\n case types.CHAR:\n return 1;\n case types.SHORT:\n return 2;\n case types.INT:\n return 4;\n case types.FLOAT:\n return 4;\n case types.DOUBLE:\n return 8;\n /* istanbul ignore next */\n default:\n return -1;\n }\n}\n\n/**\n * Reverse search of num2str\n * @ignore\n * @param {string} type - string that represents the type\n * @return {number} - parsed value of the type\n */\nfunction str2num(type) {\n switch (String(type)) {\n case 'byte':\n return types.BYTE;\n case 'char':\n return types.CHAR;\n case 'short':\n return types.SHORT;\n case 'int':\n return types.INT;\n case 'float':\n return types.FLOAT;\n case 'double':\n return types.DOUBLE;\n /* istanbul ignore next */\n default:\n return -1;\n }\n}\n\n/**\n * Auxiliary function to read numeric data\n * @ignore\n * @param {number} size - Size of the element to read\n * @param {function} bufferReader - Function to read next value\n * @return {Array|number}\n */\nfunction readNumber(size, bufferReader) {\n if (size !== 1) {\n var numbers = new Array(size);\n for (var i = 0; i < size; i++) {\n numbers[i] = bufferReader();\n }\n return numbers;\n } else {\n return bufferReader();\n }\n}\n\n/**\n * Given a type and a size reads the next element\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} type - Type of the data to read\n * @param {number} size - Size of the element to read\n * @return {string|Array|number}\n */\nfunction readType(buffer, type, size) {\n switch (type) {\n case types.BYTE:\n return buffer.readBytes(size);\n case types.CHAR:\n return trimNull(buffer.readChars(size));\n case types.SHORT:\n return readNumber(size, buffer.readInt16.bind(buffer));\n case types.INT:\n return readNumber(size, buffer.readInt32.bind(buffer));\n case types.FLOAT:\n return readNumber(size, buffer.readFloat32.bind(buffer));\n case types.DOUBLE:\n return readNumber(size, buffer.readFloat64.bind(buffer));\n /* istanbul ignore next */\n default:\n notNetcdf(true, `non valid type ${type}`);\n return undefined;\n }\n}\n\n/**\n * Removes null terminate value\n * @ignore\n * @param {string} value - String to trim\n * @return {string} - Trimmed string\n */\nfunction trimNull(value) {\n if (value.charCodeAt(value.length - 1) === 0) {\n return value.substring(0, value.length - 1);\n }\n return value;\n}\n\nmodule.exports = types;\nmodule.exports.num2str = num2str;\nmodule.exports.num2bytes = num2bytes;\nmodule.exports.str2num = str2num;\nmodule.exports.readType = readType;\n","'use strict';\n\nconst types = require('./types');\n\n// const STREAMING = 4294967295;\n\n/**\n * Read data for the given non-record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @return {Array} - Data of the element\n */\nfunction nonRecord(buffer, variable) {\n // variable type\n const type = types.str2num(variable.type);\n\n // size of the data\n var size = variable.size / types.num2bytes(type);\n\n // iterates over the data\n var data = new Array(size);\n for (var i = 0; i < size; i++) {\n data[i] = types.readType(buffer, type, 1);\n }\n\n return data;\n}\n\n/**\n * Read data for the given record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @param {object} recordDimension - Record dimension metadata\n * @return {Array} - Data of the element\n */\nfunction record(buffer, variable, recordDimension) {\n // variable type\n const type = types.str2num(variable.type);\n const width = variable.size ? variable.size / types.num2bytes(type) : 1;\n\n // size of the data\n // TODO streaming data\n var size = recordDimension.length;\n\n // iterates over the data\n var data = new Array(size);\n const step = recordDimension.recordStep;\n\n for (var i = 0; i < size; i++) {\n var currentOffset = buffer.offset;\n data[i] = types.readType(buffer, type, width);\n buffer.seek(currentOffset + step);\n }\n\n return data;\n}\n\nmodule.exports.nonRecord = nonRecord;\nmodule.exports.record = record;\n","'use strict';\n\nconst utils = require('./utils');\nconst types = require('./types');\n\n// Grammar constants\nconst ZERO = 0;\nconst NC_DIMENSION = 10;\nconst NC_VARIABLE = 11;\nconst NC_ATTRIBUTE = 12;\n\n/**\n * Read the header of the file\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} version - Version of the file\n * @return {object} - Object with the fields:\n * * `recordDimension`: Number with the length of record dimension\n * * `dimensions`: List of dimensions\n * * `globalAttributes`: List of global attributes\n * * `variables`: List of variables\n */\nfunction header(buffer, version) {\n // Length of record dimension\n // sum of the varSize's of all the record variables.\n var header = { recordDimension: { length: buffer.readUint32() } };\n\n // Version\n header.version = version;\n\n // List of dimensions\n var dimList = dimensionsList(buffer);\n header.recordDimension.id = dimList.recordId; // id of the unlimited dimension\n header.recordDimension.name = dimList.recordName; // name of the unlimited dimension\n header.dimensions = dimList.dimensions;\n\n // List of global attributes\n header.globalAttributes = attributesList(buffer);\n\n // List of variables\n var variables = variablesList(buffer, dimList.recordId, version);\n header.variables = variables.variables;\n header.recordDimension.recordStep = variables.recordStep;\n\n return header;\n}\n\nconst NC_UNLIMITED = 0;\n\n/**\n * List of dimensions\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {object} - Ojbect containing the following properties:\n * * `dimensions` that is an array of dimension object:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension dimensions: dimensions\n * * `recordId`: the id of the dimension that has unlimited size or undefined,\n * * `recordName`: name of the dimension that has unlimited size\n */\nfunction dimensionsList(buffer) {\n var recordId, recordName;\n const dimList = buffer.readUint32();\n if (dimList === ZERO) {\n utils.notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of dimensions');\n return [];\n } else {\n utils.notNetcdf((dimList !== NC_DIMENSION), 'wrong tag for list of dimensions');\n\n // Length of dimensions\n const dimensionSize = buffer.readUint32();\n var dimensions = new Array(dimensionSize);\n for (var dim = 0; dim < dimensionSize; dim++) {\n // Read name\n var name = utils.readName(buffer);\n\n // Read dimension size\n const size = buffer.readUint32();\n if (size === NC_UNLIMITED) { // in netcdf 3 one field can be of size unlimmited\n recordId = dim;\n recordName = name;\n }\n\n dimensions[dim] = {\n name: name,\n size: size\n };\n }\n }\n return {\n dimensions: dimensions,\n recordId: recordId,\n recordName: recordName\n };\n}\n\n/**\n * List of attributes\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {Array