Data Parser

The Data Parser is a utility class in JSpectraViewer that allows you to parse various data formats, including JSON, nmrML, and CSV. It automatically parses the required X, Y, peak-atom assignments (NMR), and 3D structure data (NMR). It is designed to work with the SpectraViewer1D and SpectraViewer2D classes for visualizing parsed data. It emitts a 'fileParsed' event when the file is successfully parsed, which can be used to trigger further actions in your application. The parsed data can be accessed through the `event.detail` property of the event.

Usage:

To use the DataParser, you need to initialize it with a file selector and options.The file selector should be an <input type="file"> element.

import { DataParser } from 'jsv2';
let dataParser = new DataParser("#file-selector", {  // Initialize the DataParser with the input element selector
  dataType: "1D-NMR", // Specify the type of data you expect
  expectedDataTag: "spectrumDataArray", // Optional, specify if you expect a specific tag in the data
  parserFunction: (data) => {
    // Custom parsing function if needed
    return data;
  }
});

datatype:

Specifies the type of visualization you expect to create.

string | default: "1D-NMR" | ["1D-NMR", "2D-NMR", "1D-EIMS", "1D-LCMS", "1D-IR", "1D-UV"]

expectedDataTag:

Optional. Specifies the tag in the data that contains the spectrum data array. Useful for nmrML (or any XML) data.

string | default: "spectrumDataArray" | ["spectrumDataArray", "spectrum.binary", "ms-ir-spectrum", "binary"]

parserFunction:

Optional. A custom parsing function that takes the raw data as input and returns the parsed data. Returned data structure must be an

object with the following properties:function | default: null | (data) => { return data; }