jcampconverter
Advanced tools
Comparing version 6.0.1 to 7.0.0
@@ -0,1 +1,5 @@ | ||
# [7.0.0](https://github.com/cheminfo-js/jcampconverter/compare/v6.0.1...v7.0.0) (2020-06-11) | ||
## [6.0.1](https://github.com/cheminfo-js/jcampconverter/compare/v6.0.0...v6.0.1) (2020-06-10) | ||
@@ -2,0 +6,0 @@ |
@@ -150,3 +150,2 @@ 'use strict'; | ||
spectrum.isXYdata = true; | ||
// TODO to be improved using 2 array {x:[], y:[]} | ||
let currentData = { x: [], y: [] }; | ||
@@ -780,3 +779,4 @@ spectrum.data = currentData; | ||
canonicDataLabels: true, | ||
dynamicTyping: false, | ||
canonicMetadataLabels: false, | ||
dynamicTyping: true, | ||
withoutXY: false, | ||
@@ -796,3 +796,4 @@ chromatogram: false, | ||
* @param {number} [options.keepRecordsRegExp=/^$/] By default we don't keep meta information | ||
* @param {number} [options.canonicDataLabels=true] Canonize the Labels (uppercase with symbol) | ||
* @param {number} [options.canonicDataLabels=true] Canonize the Labels (uppercase without symbol) | ||
* @param {number} [options.canonicMetadataLabels=false] Canonize the metadata Labels (uppercase without symbol) | ||
* @param {number} [options.dynamicTyping=false] Convert numbers to Number | ||
@@ -919,2 +920,3 @@ * @param {number} [options.withoutXY=false] Remove the XY data | ||
info: {}, | ||
meta: {}, | ||
}; | ||
@@ -1053,16 +1055,28 @@ parentEntry.children.push(currentEntry); | ||
currentEntry.info && | ||
currentEntry.meta && | ||
canonicDataLabel.match(options.keepRecordsRegExp) | ||
) { | ||
let label = options.canonicDataLabels ? canonicDataLabel : dataLabel; | ||
let value = dataValue.trim(); | ||
if (options.dynamicTyping && !isNaN(value)) { | ||
value = Number(value); | ||
let target, label; | ||
if (dataLabel.startsWith('$')) { | ||
label = options.canonicMetadataLabels | ||
? canonicDataLabel.substring(1) | ||
: dataLabel.substring(1); | ||
target = currentEntry.meta; | ||
} else { | ||
label = options.canonicDataLabels ? canonicDataLabel : dataLabel; | ||
target = currentEntry.info; | ||
} | ||
if (currentEntry.info[label]) { | ||
if (!Array.isArray(currentEntry.info[label])) { | ||
currentEntry.info[label] = [currentEntry.info[label]]; | ||
if (options.dynamicTyping) { | ||
let parsedValue = Number.parseFloat(value); | ||
if (!Number.isNaN(parsedValue)) value = parsedValue; | ||
} | ||
if (target[label]) { | ||
if (!Array.isArray(target[label])) { | ||
target[label] = [target[label]]; | ||
} | ||
currentEntry.info[label].push(value); | ||
target[label].push(value); | ||
} else { | ||
currentEntry.info[label] = value; | ||
target[label] = value; | ||
} | ||
@@ -1069,0 +1083,0 @@ } |
{ | ||
"name": "jcampconverter", | ||
"version": "6.0.1", | ||
"version": "7.0.0", | ||
"description": "Parse and convert JCAMP data", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -37,7 +37,7 @@ # JCAMP converter | ||
- keepRecordsRegExp - regexp to select which records should be placed in the info field. By default: :/^\$/} (nothing is kept) | ||
- xy - instead of creating a 1D array containing [x1,y1,x2,y2, ...] create an object: {x:[], y:[]} | ||
- withoutXY - do not parse XYDATA or PEAKTABLE fields. Useful to only extract metadata fields (combine this option with `keepRecordsRegExp`) | ||
- chromatogram - use the new GC/MS data format output (default: false) | ||
- canonicDataLabels - canonize data labels (uppercase) (default: true). | ||
- dynamicTyping - When parsing field convert to number if a number | ||
- canonicMetadataLabels - canonize data labels (uppercase) (default: false). | ||
- dynamicTyping - When parsing field convert to number if a number (default: true) | ||
@@ -44,0 +44,0 @@ 2D NMR options: |
@@ -19,3 +19,4 @@ import { isMSField, convertMSFieldToLabel } from './complexChromatogram'; | ||
canonicDataLabels: true, | ||
dynamicTyping: false, | ||
canonicMetadataLabels: false, | ||
dynamicTyping: true, | ||
withoutXY: false, | ||
@@ -35,3 +36,4 @@ chromatogram: false, | ||
* @param {number} [options.keepRecordsRegExp=/^$/] By default we don't keep meta information | ||
* @param {number} [options.canonicDataLabels=true] Canonize the Labels (uppercase with symbol) | ||
* @param {number} [options.canonicDataLabels=true] Canonize the Labels (uppercase without symbol) | ||
* @param {number} [options.canonicMetadataLabels=false] Canonize the metadata Labels (uppercase without symbol) | ||
* @param {number} [options.dynamicTyping=false] Convert numbers to Number | ||
@@ -158,2 +160,3 @@ * @param {number} [options.withoutXY=false] Remove the XY data | ||
info: {}, | ||
meta: {}, | ||
}; | ||
@@ -299,16 +302,28 @@ parentEntry.children.push(currentEntry); | ||
currentEntry.info && | ||
currentEntry.meta && | ||
canonicDataLabel.match(options.keepRecordsRegExp) | ||
) { | ||
let label = options.canonicDataLabels ? canonicDataLabel : dataLabel; | ||
let value = dataValue.trim(); | ||
if (options.dynamicTyping && !isNaN(value)) { | ||
value = Number(value); | ||
let target, label; | ||
if (dataLabel.startsWith('$')) { | ||
label = options.canonicMetadataLabels | ||
? canonicDataLabel.substring(1) | ||
: dataLabel.substring(1); | ||
target = currentEntry.meta; | ||
} else { | ||
label = options.canonicDataLabels ? canonicDataLabel : dataLabel; | ||
target = currentEntry.info; | ||
} | ||
if (currentEntry.info[label]) { | ||
if (!Array.isArray(currentEntry.info[label])) { | ||
currentEntry.info[label] = [currentEntry.info[label]]; | ||
if (options.dynamicTyping) { | ||
let parsedValue = Number.parseFloat(value); | ||
if (!Number.isNaN(parsedValue)) value = parsedValue; | ||
} | ||
if (target[label]) { | ||
if (!Array.isArray(target[label])) { | ||
target[label] = [target[label]]; | ||
} | ||
currentEntry.info[label].push(value); | ||
target[label].push(value); | ||
} else { | ||
currentEntry.info[label] = value; | ||
target[label] = value; | ||
} | ||
@@ -315,0 +330,0 @@ } |
@@ -10,3 +10,2 @@ export default function fastParseXYData(spectrum, value) { | ||
spectrum.isXYdata = true; | ||
// TODO to be improved using 2 array {x:[], y:[]} | ||
let currentData = { x: [], y: [] }; | ||
@@ -13,0 +12,0 @@ spectrum.data = currentData; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
83340
2033