jcampconverter 9.2.0 → 9.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/jcampconverter.cjs +8 -0
  2. package/{lib/convert.d.ts → jcampconverter.d.ts} +222 -182
  3. package/jcampconverter.mjs +8 -0
  4. package/package.json +27 -19
  5. package/lib/2d/add2D.d.ts +0 -2
  6. package/lib/2d/add2D.d.ts.map +0 -1
  7. package/lib/2d/add2D.js +0 -17
  8. package/lib/2d/add2D.js.map +0 -1
  9. package/lib/2d/convertTo3DZ.d.ts +0 -11
  10. package/lib/2d/convertTo3DZ.d.ts.map +0 -1
  11. package/lib/2d/convertTo3DZ.js +0 -59
  12. package/lib/2d/convertTo3DZ.js.map +0 -1
  13. package/lib/2d/generateContourLines.d.ts +0 -8
  14. package/lib/2d/generateContourLines.d.ts.map +0 -1
  15. package/lib/2d/generateContourLines.js +0 -163
  16. package/lib/2d/generateContourLines.js.map +0 -1
  17. package/lib/complexChromatogram.d.ts +0 -4
  18. package/lib/complexChromatogram.d.ts.map +0 -1
  19. package/lib/complexChromatogram.js +0 -49
  20. package/lib/complexChromatogram.js.map +0 -1
  21. package/lib/convert.d.ts.map +0 -1
  22. package/lib/convert.js +0 -412
  23. package/lib/convert.js.map +0 -1
  24. package/lib/convertToFloatArray.d.ts +0 -2
  25. package/lib/convertToFloatArray.d.ts.map +0 -1
  26. package/lib/convertToFloatArray.js +0 -11
  27. package/lib/convertToFloatArray.js.map +0 -1
  28. package/lib/createTree.d.ts +0 -29
  29. package/lib/createTree.d.ts.map +0 -1
  30. package/lib/createTree.js +0 -101
  31. package/lib/createTree.js.map +0 -1
  32. package/lib/index.d.ts +0 -3
  33. package/lib/index.d.ts.map +0 -1
  34. package/lib/index.js +0 -8
  35. package/lib/index.js.map +0 -1
  36. package/lib/parse/fastParseXYData.d.ts +0 -2
  37. package/lib/parse/fastParseXYData.d.ts.map +0 -1
  38. package/lib/parse/fastParseXYData.js +0 -193
  39. package/lib/parse/fastParseXYData.js.map +0 -1
  40. package/lib/parse/parsePeakTable.d.ts +0 -2
  41. package/lib/parse/parsePeakTable.d.ts.map +0 -1
  42. package/lib/parse/parsePeakTable.js +0 -67
  43. package/lib/parse/parsePeakTable.js.map +0 -1
  44. package/lib/parse/parseXYA.d.ts +0 -2
  45. package/lib/parse/parseXYA.d.ts.map +0 -1
  46. package/lib/parse/parseXYA.js +0 -51
  47. package/lib/parse/parseXYA.js.map +0 -1
  48. package/lib/postProcessing.d.ts +0 -2
  49. package/lib/postProcessing.d.ts.map +0 -1
  50. package/lib/postProcessing.js +0 -93
  51. package/lib/postProcessing.js.map +0 -1
  52. package/lib/postProcessingNMR.d.ts +0 -2
  53. package/lib/postProcessingNMR.d.ts.map +0 -1
  54. package/lib/postProcessingNMR.js +0 -95
  55. package/lib/postProcessingNMR.js.map +0 -1
  56. package/lib/prepareNtuplesDatatable.d.ts +0 -2
  57. package/lib/prepareNtuplesDatatable.d.ts.map +0 -1
  58. package/lib/prepareNtuplesDatatable.js +0 -87
  59. package/lib/prepareNtuplesDatatable.js.map +0 -1
  60. package/lib/prepareSpectrum.d.ts +0 -2
  61. package/lib/prepareSpectrum.d.ts.map +0 -1
  62. package/lib/prepareSpectrum.js +0 -10
  63. package/lib/prepareSpectrum.js.map +0 -1
  64. package/lib/profiling.d.ts +0 -2
  65. package/lib/profiling.d.ts.map +0 -1
  66. package/lib/profiling.js +0 -13
  67. package/lib/profiling.js.map +0 -1
  68. package/lib/simpleChromatogram.d.ts +0 -2
  69. package/lib/simpleChromatogram.d.ts.map +0 -1
  70. package/lib/simpleChromatogram.js +0 -16
  71. package/lib/simpleChromatogram.js.map +0 -1
  72. package/lib-esm/2d/add2D.d.ts +0 -2
  73. package/lib-esm/2d/add2D.d.ts.map +0 -1
  74. package/lib-esm/2d/add2D.js +0 -11
  75. package/lib-esm/2d/add2D.js.map +0 -1
  76. package/lib-esm/2d/convertTo3DZ.d.ts +0 -11
  77. package/lib-esm/2d/convertTo3DZ.d.ts.map +0 -1
  78. package/lib-esm/2d/convertTo3DZ.js +0 -53
  79. package/lib-esm/2d/convertTo3DZ.js.map +0 -1
  80. package/lib-esm/2d/generateContourLines.d.ts +0 -8
  81. package/lib-esm/2d/generateContourLines.d.ts.map +0 -1
  82. package/lib-esm/2d/generateContourLines.js +0 -160
  83. package/lib-esm/2d/generateContourLines.js.map +0 -1
  84. package/lib-esm/complexChromatogram.d.ts +0 -4
  85. package/lib-esm/complexChromatogram.d.ts.map +0 -1
  86. package/lib-esm/complexChromatogram.js +0 -43
  87. package/lib-esm/complexChromatogram.js.map +0 -1
  88. package/lib-esm/convert.d.ts +0 -182
  89. package/lib-esm/convert.d.ts.map +0 -1
  90. package/lib-esm/convert.js +0 -405
  91. package/lib-esm/convert.js.map +0 -1
  92. package/lib-esm/convertToFloatArray.d.ts +0 -2
  93. package/lib-esm/convertToFloatArray.d.ts.map +0 -1
  94. package/lib-esm/convertToFloatArray.js +0 -8
  95. package/lib-esm/convertToFloatArray.js.map +0 -1
  96. package/lib-esm/createTree.d.ts +0 -29
  97. package/lib-esm/createTree.d.ts.map +0 -1
  98. package/lib-esm/createTree.js +0 -97
  99. package/lib-esm/createTree.js.map +0 -1
  100. package/lib-esm/index.d.ts +0 -3
  101. package/lib-esm/index.d.ts.map +0 -1
  102. package/lib-esm/index.js +0 -3
  103. package/lib-esm/index.js.map +0 -1
  104. package/lib-esm/parse/fastParseXYData.d.ts +0 -2
  105. package/lib-esm/parse/fastParseXYData.d.ts.map +0 -1
  106. package/lib-esm/parse/fastParseXYData.js +0 -190
  107. package/lib-esm/parse/fastParseXYData.js.map +0 -1
  108. package/lib-esm/parse/parsePeakTable.d.ts +0 -2
  109. package/lib-esm/parse/parsePeakTable.d.ts.map +0 -1
  110. package/lib-esm/parse/parsePeakTable.js +0 -64
  111. package/lib-esm/parse/parsePeakTable.js.map +0 -1
  112. package/lib-esm/parse/parseXYA.d.ts +0 -2
  113. package/lib-esm/parse/parseXYA.d.ts.map +0 -1
  114. package/lib-esm/parse/parseXYA.js +0 -48
  115. package/lib-esm/parse/parseXYA.js.map +0 -1
  116. package/lib-esm/postProcessing.d.ts +0 -2
  117. package/lib-esm/postProcessing.d.ts.map +0 -1
  118. package/lib-esm/postProcessing.js +0 -87
  119. package/lib-esm/postProcessing.js.map +0 -1
  120. package/lib-esm/postProcessingNMR.d.ts +0 -2
  121. package/lib-esm/postProcessingNMR.d.ts.map +0 -1
  122. package/lib-esm/postProcessingNMR.js +0 -92
  123. package/lib-esm/postProcessingNMR.js.map +0 -1
  124. package/lib-esm/prepareNtuplesDatatable.d.ts +0 -2
  125. package/lib-esm/prepareNtuplesDatatable.d.ts.map +0 -1
  126. package/lib-esm/prepareNtuplesDatatable.js +0 -84
  127. package/lib-esm/prepareNtuplesDatatable.js.map +0 -1
  128. package/lib-esm/prepareSpectrum.d.ts +0 -2
  129. package/lib-esm/prepareSpectrum.d.ts.map +0 -1
  130. package/lib-esm/prepareSpectrum.js +0 -7
  131. package/lib-esm/prepareSpectrum.js.map +0 -1
  132. package/lib-esm/profiling.d.ts +0 -2
  133. package/lib-esm/profiling.d.ts.map +0 -1
  134. package/lib-esm/profiling.js +0 -10
  135. package/lib-esm/profiling.js.map +0 -1
  136. package/lib-esm/simpleChromatogram.d.ts +0 -2
  137. package/lib-esm/simpleChromatogram.d.ts.map +0 -1
  138. package/lib-esm/simpleChromatogram.js +0 -13
  139. package/lib-esm/simpleChromatogram.js.map +0 -1
  140. package/src/2d/add2D.js +0 -11
  141. package/src/2d/convertTo3DZ.js +0 -55
  142. package/src/2d/generateContourLines.js +0 -166
  143. package/src/complexChromatogram.js +0 -49
  144. package/src/convert.js +0 -412
  145. package/src/convertToFloatArray.js +0 -7
  146. package/src/createTree.js +0 -100
  147. package/src/index.js +0 -2
  148. package/src/parse/fastParseXYData.js +0 -175
  149. package/src/parse/parsePeakTable.js +0 -69
  150. package/src/parse/parseXYA.js +0 -50
  151. package/src/postProcessing.js +0 -93
  152. package/src/postProcessingNMR.js +0 -99
  153. package/src/prepareNtuplesDatatable.js +0 -85
  154. package/src/prepareSpectrum.js +0 -4
  155. package/src/profiling.js +0 -9
  156. package/src/simpleChromatogram.js +0 -12
package/lib/convert.js DELETED
@@ -1,412 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.convert = void 0;
7
- const dynamic_typing_1 = require("dynamic-typing");
8
- const ensure_string_1 = require("ensure-string");
9
- const complexChromatogram_1 = require("./complexChromatogram");
10
- const convertToFloatArray_1 = __importDefault(require("./convertToFloatArray"));
11
- const fastParseXYData_1 = __importDefault(require("./parse/fastParseXYData"));
12
- const parsePeakTable_1 = __importDefault(require("./parse/parsePeakTable"));
13
- const parseXYA_1 = __importDefault(require("./parse/parseXYA"));
14
- const postProcessing_1 = __importDefault(require("./postProcessing"));
15
- const prepareNtuplesDatatable_1 = __importDefault(require("./prepareNtuplesDatatable"));
16
- const prepareSpectrum_1 = __importDefault(require("./prepareSpectrum"));
17
- const profiling_1 = __importDefault(require("./profiling"));
18
- // the following RegExp can only be used for XYdata, some peakTables have values with a "E-5" ...
19
- const ntuplesSeparatorRegExp = /[ \t]*,[ \t]*/;
20
- const defaultOptions = {
21
- keepRecordsRegExp: /^$/,
22
- canonicDataLabels: true,
23
- canonicMetadataLabels: false,
24
- dynamicTyping: true,
25
- withoutXY: false,
26
- chromatogram: false,
27
- keepSpectra: false,
28
- noContour: false,
29
- nbContourLevels: 7,
30
- noiseMultiplier: 5,
31
- profiling: false,
32
- };
33
- /**
34
- * Conversion options
35
- * @typedef {object} ConvertOptions
36
- * @property {RegExp} [keepRecordsRegExp=/^$/] - By default we don't keep meta information.
37
- * @property {boolean} [canonicDataLabels=true] - Canonize the Labels (uppercase without symbol).
38
- * @property {boolean} [canonicMetadataLabels=false] - Canonize the metadata Labels (uppercase without symbol).
39
- * @property {boolean} [dynamicTyping=false] - Convert numbers to Number.
40
- * @property {boolean} [withoutXY=false] - Remove the XY data.
41
- * @property {boolean} [chromatogram=false] - Special post-processing for GC / HPLC / MS.
42
- * @property {boolean} [keepSpectra=false] - Force to keep the spectra in case of 2D.
43
- * @property {boolean} [noContour=false] - Don't calculate countour in case of 2D.
44
- * @property {number} [nbContourLevels=7] - Number of positive / negative contour levels to calculate.
45
- * @property {number} [noiseMultiplier=5] - Define for 2D the level as 5 times the median as default.
46
- * @property {import('cheminfo-types').Logger} [logger] - A logger like 'pino'
47
- * @property {boolean} [profiling=false] - Add profiling information.
48
- */
49
- /**
50
- *
51
- * @typedef {object} Ntuples
52
- * @property {string[]} [varname]
53
- * @property {string[]} [symbol]
54
- * @property {string[]} [vartype]
55
- * @property {string[]} [varform]
56
- * @property {number[]} [vardim]
57
- * @property {string[]} [units]
58
- * @property {number[]} [factor]
59
- * @property {number[]} [first]
60
- * @property {number[]} [last]
61
- * @property {number[]} [min]
62
- * @property {number[]} [max]
63
- * @property {string[]} [nucleus]
64
- */
65
- /**
66
- * @typedef { Record<string, any> } Spectrum
67
- * @property {Record<string, number[]>} [data]
68
- * @property {number} [firstX] - first X value
69
- * @property {number} [lastX] - last X value
70
- * @property {number} [deltaX] - distance between 2 consecutive x axis values
71
- * @property {number} [yFactor] - y axis scaling factor
72
- * @property {number} [xFactor] - x axis scaling factor
73
- * @property {number} [nbPoints] - Number of points
74
- */
75
- /**
76
- *
77
- * @typedef {object} MinMax
78
- * @property {number[][]} [z]
79
- * @property {number} minX
80
- * @property {number} maxX
81
- * @property {number} minY
82
- * @property {number} maxY
83
- * @property {number} minZ
84
- * @property {number} maxZ
85
- * @property {number} median
86
- */
87
- /**
88
- *
89
- * @typedef {object} Entry
90
- * @property {Spectrum[]} spectra
91
- * @property {Ntuples} ntuples
92
- * @property {object} meta
93
- * @property {object} info
94
- * @property {object} tmp
95
- * @property {string} [title]
96
- * @property {string} [dataType]
97
- * @property {string} [dataClass]
98
- * @property {boolean} [twoD]
99
- * @property {MinMax} [minMax]
100
- */
101
- /**
102
- *
103
- * @typedef { object } ConvertResult
104
- * @property { object[] | boolean } profiling
105
- * @property { string[] } logs
106
- * @property { object[] } entries
107
- * @property { Entry[] } flatten
108
- */
109
- /**
110
- * Parse a jcamp.
111
- * The data can be provide as a string or array buffer. In this later case
112
- * we will convert it first to a string before parsing.
113
- * @param {string|ArrayBuffer|Uint8Array} jcamp
114
- * @param {ConvertOptions} [options]
115
- * @returns {ConvertResult}
116
- */
117
- function convert(jcamp, options = {}) {
118
- jcamp = (0, ensure_string_1.ensureString)(jcamp);
119
- options = { ...defaultOptions, ...options };
120
- options.logger?.debug('Starting jcamp conversion');
121
- options.wantXY = !options.withoutXY;
122
- options.start = Date.now();
123
- let entriesFlat = [];
124
- let result = {
125
- profiling: options.profiling ? [] : false,
126
- logs: [],
127
- entries: [],
128
- };
129
- let tmpResult = { children: [] };
130
- let currentEntry = tmpResult;
131
- let parentsStack = [];
132
- let spectrum = {};
133
- if (typeof jcamp !== 'string') {
134
- throw new TypeError('the JCAMP should be a string');
135
- }
136
- (0, profiling_1.default)(result, 'Before split to LDRS', options);
137
- let ldrs = jcamp.replace(/[\r\n]+##/g, '\n##').split('\n##');
138
- (0, profiling_1.default)(result, 'Split to LDRS', options);
139
- if (ldrs[0])
140
- ldrs[0] = ldrs[0].replace(/^[\r\n ]*##/, '');
141
- for (let ldr of ldrs) {
142
- // This is a new LDR
143
- let position = ldr.indexOf('=');
144
- let dataLabel = position > 0 ? ldr.substring(0, position) : ldr;
145
- let dataValue = position > 0 ? ldr.substring(position + 1).trim() : '';
146
- let canonicDataLabel = dataLabel.replace(/[_ -]/g, '').toUpperCase();
147
- if (canonicDataLabel === 'DATATABLE') {
148
- let endLine = dataValue.indexOf('\n');
149
- if (endLine === -1)
150
- endLine = dataValue.indexOf('\r');
151
- if (endLine > 0) {
152
- // ##DATA TABLE= (X++(I..I)), XYDATA
153
- // We need to find the variables
154
- let infos = dataValue.substring(0, endLine).split(/[ ,;\t]+/);
155
- (0, prepareNtuplesDatatable_1.default)(currentEntry, spectrum, infos[0]);
156
- spectrum.datatable = infos[0];
157
- if (infos[1] && infos[1].indexOf('PEAKS') > -1) {
158
- canonicDataLabel = 'PEAKTABLE';
159
- }
160
- else if (infos[1] &&
161
- (infos[1].indexOf('XYDATA') || infos[0].indexOf('++') > 0)) {
162
- canonicDataLabel = 'XYDATA';
163
- if (spectrum.nbPoints) {
164
- spectrum.deltaX =
165
- (spectrum.lastX - spectrum.firstX) / (spectrum.nbPoints - 1);
166
- }
167
- }
168
- }
169
- }
170
- if (canonicDataLabel === 'XYDATA') {
171
- if (options.wantXY) {
172
- (0, prepareSpectrum_1.default)(spectrum);
173
- // well apparently we should still consider it is a PEAK TABLE if there are no '++' after
174
- if (dataValue.match(/.*\+\+.*/)) {
175
- // ex: (X++(Y..Y))
176
- if (spectrum.nbPoints) {
177
- spectrum.deltaX =
178
- (spectrum.lastX - spectrum.firstX) / (spectrum.nbPoints - 1);
179
- }
180
- (0, fastParseXYData_1.default)(spectrum, dataValue, result);
181
- }
182
- else {
183
- (0, parsePeakTable_1.default)(spectrum, dataValue, result);
184
- }
185
- currentEntry.spectra.push(spectrum);
186
- spectrum = {};
187
- }
188
- continue;
189
- }
190
- else if (canonicDataLabel === 'PEAKTABLE') {
191
- if (options.wantXY) {
192
- (0, prepareSpectrum_1.default)(spectrum);
193
- (0, parsePeakTable_1.default)(spectrum, dataValue, result);
194
- currentEntry.spectra.push(spectrum);
195
- spectrum = {};
196
- }
197
- continue;
198
- }
199
- if (canonicDataLabel === 'PEAKASSIGNMENTS') {
200
- if (options.wantXY) {
201
- if (dataValue.match(/.*([^A-Z]*).*/)) {
202
- // ex: (XYA)
203
- (0, parseXYA_1.default)(spectrum, dataValue);
204
- }
205
- currentEntry.spectra.push(spectrum);
206
- spectrum = {};
207
- }
208
- continue;
209
- }
210
- if (canonicDataLabel === 'TITLE') {
211
- let parentEntry = currentEntry;
212
- if (!parentEntry.children) {
213
- parentEntry.children = [];
214
- }
215
- currentEntry = {
216
- spectra: [],
217
- ntuples: {},
218
- info: {},
219
- meta: {},
220
- tmp: {}, // tmp information we need to keep for postprocessing
221
- };
222
- parentEntry.children.push(currentEntry);
223
- parentsStack.push(parentEntry);
224
- entriesFlat.push(currentEntry);
225
- currentEntry.title = dataValue;
226
- }
227
- else if (canonicDataLabel === 'DATATYPE') {
228
- currentEntry.dataType = dataValue;
229
- if (dataValue.match(/(^nd|\snd\s)/i)) {
230
- currentEntry.twoD = true;
231
- }
232
- }
233
- else if (canonicDataLabel === 'NTUPLES') {
234
- if (dataValue.match(/(^nd|\snd\s)/i)) {
235
- currentEntry.twoD = true;
236
- }
237
- }
238
- else if (canonicDataLabel === 'DATACLASS') {
239
- currentEntry.dataClass = dataValue;
240
- }
241
- else if (canonicDataLabel === 'XUNITS') {
242
- spectrum.xUnits = dataValue;
243
- }
244
- else if (canonicDataLabel === 'YUNITS') {
245
- spectrum.yUnits = dataValue;
246
- }
247
- else if (canonicDataLabel === 'FIRSTX') {
248
- spectrum.firstX = Number(dataValue);
249
- }
250
- else if (canonicDataLabel === 'LASTX') {
251
- spectrum.lastX = Number(dataValue);
252
- }
253
- else if (canonicDataLabel === 'FIRSTY') {
254
- spectrum.firstY = Number(dataValue);
255
- }
256
- else if (canonicDataLabel === 'LASTY') {
257
- spectrum.lastY = Number(dataValue);
258
- }
259
- else if (canonicDataLabel === 'NPOINTS') {
260
- spectrum.nbPoints = Number(dataValue);
261
- }
262
- else if (canonicDataLabel === 'XFACTOR') {
263
- spectrum.xFactor = Number(dataValue);
264
- }
265
- else if (canonicDataLabel === 'YFACTOR') {
266
- spectrum.yFactor = Number(dataValue);
267
- }
268
- else if (canonicDataLabel === 'MAXX') {
269
- spectrum.maxX = Number(dataValue);
270
- }
271
- else if (canonicDataLabel === 'MINX') {
272
- spectrum.minX = Number(dataValue);
273
- }
274
- else if (canonicDataLabel === 'MAXY') {
275
- spectrum.maxY = Number(dataValue);
276
- }
277
- else if (canonicDataLabel === 'MINY') {
278
- spectrum.minY = Number(dataValue);
279
- }
280
- else if (canonicDataLabel === 'DELTAX') {
281
- spectrum.deltaX = Number(dataValue);
282
- }
283
- else if (canonicDataLabel === '.OBSERVEFREQUENCY' ||
284
- canonicDataLabel === '$SFO1') {
285
- if (!spectrum.observeFrequency) {
286
- spectrum.observeFrequency = Number(dataValue);
287
- }
288
- }
289
- else if (canonicDataLabel === '.OBSERVENUCLEUS') {
290
- if (!spectrum.xType) {
291
- currentEntry.xType = dataValue.replace(/[^a-zA-Z0-9]/g, '');
292
- }
293
- }
294
- else if (canonicDataLabel === '$OFFSET') {
295
- // OFFSET for Bruker spectra
296
- currentEntry.shiftOffsetNum = 0;
297
- if (!spectrum.shiftOffsetVal) {
298
- spectrum.shiftOffsetVal = Number(dataValue);
299
- }
300
- }
301
- else if (canonicDataLabel === '$REFERENCEPOINT') {
302
- // OFFSET for Varian spectra
303
- // if we activate this part it does not work for ACD specmanager
304
- // } else if (canonicDataLabel=='.SHIFTREFERENCE') { // OFFSET FOR Bruker Spectra
305
- // var parts = dataValue.split(/ *, */);
306
- // currentEntry.shiftOffsetNum = parseInt(parts[2].trim());
307
- // spectrum.shiftOffsetVal = Number(parts[3].trim());
308
- }
309
- else if (canonicDataLabel === 'VARNAME') {
310
- currentEntry.ntuples.varname = dataValue.split(ntuplesSeparatorRegExp);
311
- }
312
- else if (canonicDataLabel === 'SYMBOL') {
313
- currentEntry.ntuples.symbol = dataValue.split(ntuplesSeparatorRegExp);
314
- }
315
- else if (canonicDataLabel === 'VARTYPE') {
316
- currentEntry.ntuples.vartype = dataValue.split(ntuplesSeparatorRegExp);
317
- }
318
- else if (canonicDataLabel === 'VARFORM') {
319
- currentEntry.ntuples.varform = dataValue.split(ntuplesSeparatorRegExp);
320
- }
321
- else if (canonicDataLabel === 'VARDIM') {
322
- currentEntry.ntuples.vardim = (0, convertToFloatArray_1.default)(dataValue.split(ntuplesSeparatorRegExp));
323
- }
324
- else if (canonicDataLabel === 'UNITS') {
325
- currentEntry.ntuples.units = dataValue.split(ntuplesSeparatorRegExp);
326
- }
327
- else if (canonicDataLabel === 'FACTOR') {
328
- currentEntry.ntuples.factor = (0, convertToFloatArray_1.default)(dataValue.split(ntuplesSeparatorRegExp));
329
- }
330
- else if (canonicDataLabel === 'FIRST') {
331
- currentEntry.ntuples.first = (0, convertToFloatArray_1.default)(dataValue.split(ntuplesSeparatorRegExp));
332
- }
333
- else if (canonicDataLabel === 'LAST') {
334
- currentEntry.ntuples.last = (0, convertToFloatArray_1.default)(dataValue.split(ntuplesSeparatorRegExp));
335
- }
336
- else if (canonicDataLabel === 'MIN') {
337
- currentEntry.ntuples.min = (0, convertToFloatArray_1.default)(dataValue.split(ntuplesSeparatorRegExp));
338
- }
339
- else if (canonicDataLabel === 'MAX') {
340
- currentEntry.ntuples.max = (0, convertToFloatArray_1.default)(dataValue.split(ntuplesSeparatorRegExp));
341
- }
342
- else if (canonicDataLabel === '.NUCLEUS') {
343
- if (currentEntry.ntuples) {
344
- currentEntry.ntuples.nucleus = dataValue.split(ntuplesSeparatorRegExp);
345
- }
346
- }
347
- else if (canonicDataLabel === 'PAGE') {
348
- spectrum.page = dataValue.trim();
349
- spectrum.pageValue = Number(dataValue.replace(/^.*=/, ''));
350
- spectrum.pageSymbol = spectrum.page.replace(/[=].*/, '');
351
- }
352
- else if (canonicDataLabel === 'RETENTIONTIME') {
353
- spectrum.pageValue = Number(dataValue);
354
- }
355
- else if ((0, complexChromatogram_1.isMSField)(canonicDataLabel)) {
356
- spectrum[(0, complexChromatogram_1.convertMSFieldToLabel)(canonicDataLabel)] = dataValue;
357
- }
358
- else if (canonicDataLabel === 'SAMPLEDESCRIPTION') {
359
- spectrum.sampleDescription = dataValue;
360
- }
361
- else if (canonicDataLabel.startsWith('$NUC')) {
362
- if (!currentEntry.tmp[canonicDataLabel] && !dataValue.includes('off')) {
363
- currentEntry.tmp[canonicDataLabel] = dataValue.replace(/[<>]/g, '');
364
- }
365
- }
366
- else if (canonicDataLabel === 'END') {
367
- currentEntry = parentsStack.pop();
368
- }
369
- if (currentEntry &&
370
- currentEntry.info &&
371
- currentEntry.meta &&
372
- canonicDataLabel.match(options.keepRecordsRegExp)) {
373
- let value = dataValue.trim();
374
- let target, label;
375
- if (dataLabel.startsWith('$')) {
376
- label = options.canonicMetadataLabels
377
- ? canonicDataLabel.substring(1)
378
- : dataLabel.substring(1);
379
- target = currentEntry.meta;
380
- }
381
- else {
382
- label = options.canonicDataLabels ? canonicDataLabel : dataLabel;
383
- target = currentEntry.info;
384
- }
385
- if (options.dynamicTyping) {
386
- value = (0, dynamic_typing_1.parseString)(value);
387
- }
388
- if (target[label]) {
389
- if (!Array.isArray(target[label])) {
390
- target[label] = [target[label]];
391
- }
392
- target[label].push(value);
393
- }
394
- else {
395
- target[label] = value;
396
- }
397
- }
398
- }
399
- (0, profiling_1.default)(result, 'Finished parsing', options);
400
- (0, postProcessing_1.default)(entriesFlat, result, options);
401
- (0, profiling_1.default)(result, 'Total time', options);
402
- /*
403
- if (result.children && result.children.length>0) {
404
- result = { ...result, ...result.children[0] };
405
- }
406
- */
407
- result.entries = tmpResult.children;
408
- result.flatten = entriesFlat;
409
- return result;
410
- }
411
- exports.convert = convert;
412
- //# sourceMappingURL=convert.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convert.js","sourceRoot":"","sources":["../src/convert.js"],"names":[],"mappings":";;;;;;AAAA,mDAA6C;AAC7C,iDAA6C;AAE7C,+DAAyE;AACzE,gFAAwD;AACxD,8EAAsD;AACtD,4EAAoD;AACpD,gEAAwC;AACxC,sEAA8C;AAC9C,wFAAgE;AAChE,wEAAgD;AAChD,4DAAoC;AAEpC,iGAAiG;AACjG,MAAM,sBAAsB,GAAG,eAAe,CAAC;AAE/C,MAAM,cAAc,GAAG;IACrB,iBAAiB,EAAE,IAAI;IACvB,iBAAiB,EAAE,IAAI;IACvB,qBAAqB,EAAE,KAAK;I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AAC,CAAC,CAAC,SAAS,CAAC;gBACjE,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC;aAC5B;YAED,IAAI,OAAO,CAAC,aAAa,EAAE;gBACzB,KAAK,GAAG,IAAA,4BAAW,EAAC,KAAK,CAAC,CAAC;aAC5B;YACD,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE;gBACjB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE;oBACjC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;iBACjC;gBACD,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAC3B;iBAAM;gBACL,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;aACvB;SACF;KACF;IAED,IAAA,mBAAS,EAAC,MAAM,EAAE,kBAAkB,EAAE,OAAO,CAAC,CAAC;IAE/C,IAAA,wBAAc,EAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAE7C,IAAA,mBAAS,EAAC,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;IAEzC;;;;MAIE;IACF,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC;IACpC,MAAM,CAAC,OAAO,GAAG,WAAW,CAAC;IAE7B,OAAO,MAAM,CAAC;AAChB,CAAC;AAnSD,0BAmSC"}
@@ -1,2 +0,0 @@
1
- export default function convertToFloatArray(stringArray: any): number[];
2
- //# sourceMappingURL=convertToFloatArray.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convertToFloatArray.d.ts","sourceRoot":"","sources":["../src/convertToFloatArray.js"],"names":[],"mappings":"AAAA,wEAMC"}
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function convertToFloatArray(stringArray) {
4
- let floatArray = [];
5
- for (let i = 0; i < stringArray.length; i++) {
6
- floatArray.push(Number(stringArray[i]));
7
- }
8
- return floatArray;
9
- }
10
- exports.default = convertToFloatArray;
11
- //# sourceMappingURL=convertToFloatArray.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convertToFloatArray.js","sourceRoot":"","sources":["../src/convertToFloatArray.js"],"names":[],"mappings":";;AAAA,SAAwB,mBAAmB,CAAC,WAAW;IACrD,IAAI,UAAU,GAAG,EAAE,CAAC;IACpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC3C,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KACzC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAND,sCAMC"}
@@ -1,29 +0,0 @@
1
- /**
2
- *
3
- * @typedef {object} CreateTreeOptions
4
- * @property {boolean} [flatten=false]
5
- */
6
- /**
7
- *
8
- * @typedef {object} Tree
9
- * @property {string} title
10
- * @property {string} jcamp
11
- * @property {Tree[]} [children]
12
- */
13
- /**
14
- * Parse the jcamp to extract the structure as a tree.
15
- *
16
- * @param {string|ArrayBuffer|Uint8Array} jcamp
17
- * @param {CreateTreeOptions} [options={}]
18
- * @returns {Tree[]}
19
- */
20
- export function createTree(jcamp: string | ArrayBuffer | Uint8Array, options?: CreateTreeOptions | undefined): Tree[];
21
- export type CreateTreeOptions = {
22
- flatten?: boolean | undefined;
23
- };
24
- export type Tree = {
25
- title: string;
26
- jcamp: string;
27
- children?: Tree[] | undefined;
28
- };
29
- //# sourceMappingURL=createTree.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createTree.d.ts","sourceRoot":"","sources":["../src/createTree.js"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH;;;;;;GAMG;AAEH;;;;;;GAMG;AACH,kCAJW,MAAM,GAAC,WAAW,GAAC,UAAU,4CAE3B,IAAI,EAAE,CA8ElB;;;;;WAxFa,MAAM;WACN,MAAM"}
package/lib/createTree.js DELETED
@@ -1,101 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createTree = void 0;
4
- const ensure_string_1 = require("ensure-string");
5
- /**
6
- *
7
- * @typedef {object} CreateTreeOptions
8
- * @property {boolean} [flatten=false]
9
- */
10
- /**
11
- *
12
- * @typedef {object} Tree
13
- * @property {string} title
14
- * @property {string} jcamp
15
- * @property {Tree[]} [children]
16
- */
17
- /**
18
- * Parse the jcamp to extract the structure as a tree.
19
- *
20
- * @param {string|ArrayBuffer|Uint8Array} jcamp
21
- * @param {CreateTreeOptions} [options={}]
22
- * @returns {Tree[]}
23
- */
24
- function createTree(jcamp, options = {}) {
25
- jcamp = (0, ensure_string_1.ensureString)(jcamp);
26
- const { flatten = false } = options;
27
- if (typeof jcamp !== 'string') {
28
- throw new TypeError('the JCAMP should be a string');
29
- }
30
- let lines = jcamp.split(/[\r\n]+/);
31
- let flat = [];
32
- let stack = [];
33
- let result = [];
34
- let current;
35
- let ntupleLevel = 0;
36
- let spaces = jcamp.includes('## ');
37
- for (let i = 0; i < lines.length; i++) {
38
- let line = lines[i];
39
- let labelLine = spaces ? line.replace(/ /g, '') : line;
40
- if (labelLine.substring(0, 9) === '##NTUPLES') {
41
- ntupleLevel++;
42
- }
43
- if (labelLine.substring(0, 7) === '##TITLE') {
44
- let title = [labelLine.substring(8).trim()];
45
- for (let j = i + 1; j < lines.length; j++) {
46
- if (lines[j].startsWith('##')) {
47
- break;
48
- }
49
- else {
50
- title.push(lines[j].trim());
51
- }
52
- }
53
- stack.push({
54
- title: title.join('\n'),
55
- jcamp: `${line}\n`,
56
- children: [],
57
- });
58
- current = stack[stack.length - 1];
59
- flat.push(current);
60
- }
61
- else if (labelLine.substring(0, 5) === '##END' && ntupleLevel === 0) {
62
- current.jcamp += `${line}\n`;
63
- let finished = stack.pop();
64
- if (stack.length !== 0) {
65
- current = stack[stack.length - 1];
66
- current.children.push(finished);
67
- }
68
- else {
69
- current = undefined;
70
- result.push(finished);
71
- }
72
- }
73
- else if (current && current.jcamp) {
74
- current.jcamp += `${line}\n`;
75
- let match = labelLine.match(/^##(.*?)=(.+)/);
76
- if (match) {
77
- let canonicDataLabel = match[1].replace(/[ _-]/g, '').toUpperCase();
78
- if (canonicDataLabel === 'DATATYPE') {
79
- current.dataType = match[2].trim();
80
- }
81
- if (canonicDataLabel === 'DATACLASS') {
82
- current.dataClass = match[2].trim();
83
- }
84
- }
85
- }
86
- if (labelLine.substring(0, 5) === '##END' && ntupleLevel > 0) {
87
- ntupleLevel--;
88
- }
89
- }
90
- if (flatten) {
91
- flat.forEach((entry) => {
92
- entry.children = undefined;
93
- });
94
- return flat;
95
- }
96
- else {
97
- return result;
98
- }
99
- }
100
- exports.createTree = createTree;
101
- //# sourceMappingURL=createTree.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createTree.js","sourceRoot":"","sources":["../src/createTree.js"],"names":[],"mappings":";;;AAAA,iDAA6C;AAE7C;;;;GAIG;AAEH;;;;;;GAMG;AAEH;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,EAAE;IAC5C,KAAK,GAAG,IAAA,4BAAY,EAAC,KAAK,CAAC,CAAC;IAC5B,MAAM,EAAE,OAAO,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,MAAM,IAAI,SAAS,CAAC,8BAA8B,CAAC,CAAC;KACrD;IAED,IAAI,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACnC,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,OAAO,CAAC;IACZ,IAAI,WAAW,GAAG,CAAC,CAAC;IAEpB,IAAI,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC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AAE;YACrB,KAAK,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;KACb;SAAM;QACL,OAAO,MAAM,CAAC;KACf;AACH,CAAC;AA5ED,gCA4EC"}
package/lib/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export { createTree } from "./createTree";
2
- export { convert } from "./convert";
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}
package/lib/index.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convert = exports.createTree = void 0;
4
- var createTree_1 = require("./createTree");
5
- Object.defineProperty(exports, "createTree", { enumerable: true, get: function () { return createTree_1.createTree; } });
6
- var convert_1 = require("./convert");
7
- Object.defineProperty(exports, "convert", { enumerable: true, get: function () { return convert_1.convert; } });
8
- //# sourceMappingURL=index.js.map
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";;;AAAA,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA"}
@@ -1,2 +0,0 @@
1
- export default function fastParseXYData(spectrum: any, value: any): void;
2
- //# sourceMappingURL=fastParseXYData.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fastParseXYData.d.ts","sourceRoot":"","sources":["../../src/parse/fastParseXYData.js"],"names":[],"mappings":"AAAA,yEA8KC"}