Comparing version 1.4.8 to 1.5.0
{ | ||
"name": "mf-parser", | ||
"version": "1.4.8", | ||
"version": "1.5.0", | ||
"description": "Parse a molecular formula", | ||
"main": "lib/index.js", | ||
"module": "src/index.js", | ||
"main": "src/index.js", | ||
"files": [ | ||
"src", | ||
"lib" | ||
"src" | ||
], | ||
@@ -21,8 +19,7 @@ "repository": { | ||
}, | ||
"homepage": "https://github.com/cheminfo/mass-tools/tree/main/packages/mf-parser#readme", | ||
"homepage": "https://github.com/cheminfo/mass-tools/tree/master/packages/mf-parser#readme", | ||
"dependencies": { | ||
"atom-sorter": "^1.1.11", | ||
"chemical-elements": "^1.2.4", | ||
"chemical-groups": "^1.2.2", | ||
"mf-utilities": "^1.4.2" | ||
"atom-sorter": "^1.2.0", | ||
"chemical-elements": "^1.3.0", | ||
"chemical-groups": "^1.3.0" | ||
}, | ||
@@ -32,3 +29,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "bd2c06e05f2196c5f9c6ff011cf3ef41e1b6a0f9" | ||
"gitHead": "ade929b07af4e2f0f8b3fe1aaf0df70c50f4b2db" | ||
} |
@@ -1,4 +0,5 @@ | ||
// import { capitalizeMF as ensureCase } from '../util/capitalizeMF.js'; | ||
import { ensureCase } from '../ensureCase.js'; | ||
'use strict'; | ||
const ensureCase = require('../ensureCase'); | ||
test('ensureCase', () => { | ||
@@ -5,0 +6,0 @@ expect(ensureCase('ch3cooh')).toBe('CH3COOH'); |
@@ -1,7 +0,9 @@ | ||
import { toMatchCloseTo } from 'jest-matcher-deep-close-to'; | ||
'use strict'; | ||
import { MF } from '../MF'; | ||
const toMatchCloseTo = require('jest-matcher-deep-close-to').toMatchCloseTo; | ||
expect.extend({ toMatchCloseTo }); | ||
let MF = require('../MF'); | ||
test('getEA', () => { | ||
@@ -8,0 +10,0 @@ expect(new MF('C').getEA()).toMatchCloseTo( |
@@ -1,7 +0,9 @@ | ||
import { toMatchCloseTo } from 'jest-matcher-deep-close-to'; | ||
'use strict'; | ||
import { MF } from '..'; | ||
const toMatchCloseTo = require('jest-matcher-deep-close-to').toMatchCloseTo; | ||
expect.extend({ toMatchCloseTo }); | ||
let MF = require('../MF'); | ||
test('getElements', () => { | ||
@@ -8,0 +10,0 @@ expect(new MF('C2').getElements()).toStrictEqual([ |
@@ -1,3 +0,5 @@ | ||
import { MF } from '../MF'; | ||
'use strict'; | ||
let MF = require('../MF'); | ||
test('getIsotopesInfo from C{50,50}[13C]H2', () => { | ||
@@ -4,0 +6,0 @@ let mf = new MF('[13C]3CC{50,50}((2+))2'); |
@@ -1,3 +0,5 @@ | ||
import { MF } from '..'; | ||
'use strict'; | ||
const MF = require('../MF'); | ||
describe('MF', () => { | ||
@@ -4,0 +6,0 @@ it('C', () => { |
@@ -1,3 +0,5 @@ | ||
import { parse } from '../parse'; | ||
'use strict'; | ||
const parse = require('../parse'); | ||
let tests = { | ||
@@ -4,0 +6,0 @@ C10: [ |
@@ -1,6 +0,6 @@ | ||
import { elementsObject } from 'chemical-elements'; | ||
'use strict'; | ||
const elements = Object.keys(elementsObject).sort( | ||
(a, b) => b.length - a.length, | ||
); | ||
const elements = Object.keys( | ||
require('chemical-elements/src/elementsAndStableIsotopesObject.js'), | ||
).sort((a, b) => b.length - a.length); | ||
@@ -13,3 +13,3 @@ /** | ||
export function ensureCase(mf) { | ||
function capitalize(mf) { | ||
for (let i = 0; i < mf.length; i++) { | ||
@@ -40,6 +40,8 @@ if (mf.charCodeAt(i) > 64 && mf.charCodeAt(i) < 91) { | ||
j++; | ||
} else if (elements.includes(one)) { | ||
newPart += one; | ||
} else { | ||
return mf; | ||
if (elements.includes(one)) { | ||
newPart += one; | ||
} else { | ||
return mf; | ||
} | ||
} | ||
@@ -53,1 +55,3 @@ } | ||
} | ||
module.exports = capitalize; |
@@ -0,1 +1,3 @@ | ||
'use strict'; | ||
/** | ||
@@ -5,3 +7,3 @@ * Defines static variables corresponding to the various formatting possibilities | ||
export const Format = { | ||
module.exports = { | ||
SUBSCRIPT: 'subscript', | ||
@@ -8,0 +10,0 @@ SUPERSCRIPT: 'superscript', |
@@ -1,10 +0,30 @@ | ||
export * from './parse.js'; | ||
export * from './util/subSuperscript.js'; | ||
export * from './util/toDisplay.js'; | ||
export * from './util/toHtml.js'; | ||
export * from './Kind.js'; | ||
export * from './Format.js'; | ||
export * from './Style.js'; | ||
export * from './ensureCase.js'; | ||
export * from './MF.js'; | ||
export * from './parseToHtml.js'; | ||
'use strict'; | ||
const parse = require('./parse'); | ||
const { subscript, superscript } = require('./util/subSuperscript'); | ||
const toDisplay = require('./util/toDisplay'); | ||
const toHtml = require('./util/toHtml'); | ||
/** | ||
* Parse a molecular formula and converts it to an HTML code | ||
* @param {String} mf String containing the molecular formula | ||
*/ | ||
function parseToHtml(mf) { | ||
let parsed = parse(mf); | ||
let display = toDisplay(parsed); | ||
return toHtml(display); | ||
} | ||
module.exports = { | ||
Kind: require('./Kind'), | ||
Format: require('./Format'), | ||
Style: require('./Style'), | ||
parse: require('./parse'), | ||
ensureCase: require('./ensureCase'), | ||
toDisplay, | ||
toHtml, | ||
parseToHtml, | ||
subscript, | ||
superscript, | ||
MF: require('./MF'), | ||
}; |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
/** | ||
@@ -5,3 +6,3 @@ * Define static variable corresponding to the various Kinds of a molecular formula part. | ||
export const Kind = { | ||
module.exports = { | ||
BEGIN: 'begin', | ||
@@ -8,0 +9,0 @@ ATOM: 'atom', |
@@ -1,18 +0,17 @@ | ||
import { ensureCase } from './ensureCase'; | ||
import { parse } from './parse'; | ||
import { getEA } from './util/getEA'; | ||
import { getElements } from './util/getElements'; | ||
import { getInfo } from './util/getInfo'; | ||
import { getIsotopesInfo } from './util/getIsotopesInfo'; | ||
import { partsToDisplay } from './util/partsToDisplay'; | ||
import { partsToMF } from './util/partsToMF'; | ||
import { toDisplay } from './util/toDisplay'; | ||
import { toHtml } from './util/toHtml'; | ||
import { toParts } from './util/toParts'; | ||
import { toText } from './util/toText'; | ||
'use strict'; | ||
/** | ||
* Class allowing to deal with molecular formula and derived information | ||
*/ | ||
export class MF { | ||
const ensureCase = require('./ensureCase'); | ||
const parse = require('./parse'); | ||
const getEA = require('./util/getEA'); | ||
const getElements = require('./util/getElements'); | ||
const getInfo = require('./util/getInfo'); | ||
const getIsotopesInfo = require('./util/getIsotopesInfo'); | ||
const partsToDisplay = require('./util/partsToDisplay'); | ||
const partsToMF = require('./util/partsToMF'); | ||
const toDisplay = require('./util/toDisplay'); | ||
const toHtml = require('./util/toHtml'); | ||
const toParts = require('./util/toParts'); | ||
const toText = require('./util/toText'); | ||
class MF { | ||
constructor(mf, options = {}) { | ||
@@ -136,1 +135,3 @@ if (options.ensureCase) { | ||
} | ||
module.exports = MF; |
@@ -1,4 +0,6 @@ | ||
import { Kind } from './Kind'; | ||
import { parseCharge } from './util/parseCharge'; | ||
'use strict'; | ||
const Kind = require('./Kind'); | ||
const parseCharge = require('./util/parseCharge'); | ||
/** | ||
@@ -9,5 +11,5 @@ * Parse a mf to an array of kind / value | ||
export function parse(mf) { | ||
module.exports = function parse(mf) { | ||
return new MFParser().parse(mf); | ||
} | ||
}; | ||
@@ -57,12 +59,14 @@ class MFParser { | ||
this.result[this.result.length - 1].value = value.from; | ||
} else if (value.to) { | ||
this.result.push({ | ||
kind: Kind.MULTIPLIER_RANGE, | ||
value: { | ||
from: Math.min(value.from, value.to), | ||
to: Math.max(value.from, value.to), | ||
}, | ||
}); | ||
} else { | ||
this.result.push({ kind: Kind.MULTIPLIER, value: value.from }); | ||
if (value.to) { | ||
this.result.push({ | ||
kind: Kind.MULTIPLIER_RANGE, | ||
value: { | ||
from: Math.min(value.from, value.to), | ||
to: Math.max(value.from, value.to), | ||
}, | ||
}); | ||
} else { | ||
this.result.push({ kind: Kind.MULTIPLIER, value: value.from }); | ||
} | ||
} | ||
@@ -69,0 +73,0 @@ continue; |
@@ -1,2 +0,4 @@ | ||
export const Style = { | ||
'use strict'; | ||
module.exports = { | ||
SUPERIMPOSE: | ||
@@ -3,0 +5,0 @@ 'flex-direction: column;display: inline-flex;justify-content: center;text-align: left;vertical-align: middle;', |
@@ -1,3 +0,5 @@ | ||
import { capitalizeMF } from '../capitalizeMF'; | ||
'use strict'; | ||
const capitalizeMF = require('../capitalizeMF'); | ||
const tests = [ | ||
@@ -4,0 +6,0 @@ ['triethylamine', 'triethylamine'], |
@@ -1,3 +0,5 @@ | ||
import { formatCharge } from '../formatCharge'; | ||
'use strict'; | ||
const formatCharge = require('../formatCharge'); | ||
test('formatCharge', () => { | ||
@@ -4,0 +6,0 @@ expect(formatCharge(-2)).toBe('-2'); |
@@ -1,11 +0,13 @@ | ||
import { parseCharge } from '../parseCharge'; | ||
'use strict'; | ||
test('parseCharge', () => { | ||
expect(parseCharge('---')).toBe(-3); | ||
expect(parseCharge('+++')).toBe(3); | ||
expect(parseCharge('---++')).toBe(-1); | ||
expect(parseCharge('(-3)')).toBe(-3); | ||
expect(parseCharge('(+1)')).toBe(1); | ||
expect(parseCharge('(---)')).toBe(-3); | ||
expect(parseCharge('(++)')).toBe(2); | ||
const getCharge = require('../parseCharge'); | ||
test('getCharge', () => { | ||
expect(getCharge('---')).toBe(-3); | ||
expect(getCharge('+++')).toBe(3); | ||
expect(getCharge('---++')).toBe(-1); | ||
expect(getCharge('(-3)')).toBe(-3); | ||
expect(getCharge('(+1)')).toBe(1); | ||
expect(getCharge('(---)')).toBe(-3); | ||
expect(getCharge('(++)')).toBe(2); | ||
}); |
@@ -1,3 +0,5 @@ | ||
import { toDisplay } from '../toDisplay'; | ||
'use strict'; | ||
const toDisplay = require('../toDisplay'); | ||
let tests = [ | ||
@@ -4,0 +6,0 @@ { |
@@ -1,4 +0,6 @@ | ||
import { parse } from '../../parse'; | ||
import { toParts } from '../toParts'; | ||
'use strict'; | ||
const parse = require('../../parse'); | ||
const toParts = require('../toParts'); | ||
let tests = [ | ||
@@ -5,0 +7,0 @@ { mf: 'C', result: [[{ kind: 'atom', value: 'C', multiplier: 1 }]] }, |
@@ -1,5 +0,8 @@ | ||
import { elementsObject } from 'chemical-elements'; | ||
import { groupsObject } from 'chemical-groups'; | ||
import { isMF } from 'mf-utilities'; | ||
'use strict'; | ||
const elements = require('chemical-elements').elementsObject; | ||
const groups = require('chemical-groups').getGroupsObject(); | ||
const isMF = require('../../../mf-utilities/src/isMF'); | ||
/** | ||
@@ -9,3 +12,3 @@ * Try to capitalize a molecular formula based on what end users 'would' expect | ||
export function capitalizeMF(mf) { | ||
module.exports = function capitalizeMF(mf) { | ||
if (!mf.match(/^[0-9a-zA-Z ]+/)) return mf; | ||
@@ -35,7 +38,7 @@ if (isMF(mf)) return mf; | ||
return newMF; | ||
} | ||
}; | ||
function getCasedLabel(label) { | ||
if (elementsObject[label]) return label; | ||
if (groupsObject[label]) return label; | ||
if (elements[label]) return label; | ||
if (groups[label]) return label; | ||
@@ -46,4 +49,4 @@ if (label === '') return label; | ||
label.substr(0, 1).toUpperCase() + label.substr(1).toLowerCase(); | ||
if (elementsObject[label]) return casedLabel; | ||
if (groupsObject[label]) return casedLabel; | ||
if (elements[label]) return casedLabel; | ||
if (groups[label]) return casedLabel; | ||
@@ -50,0 +53,0 @@ // we would like to cover chcl3, ch2o, ch2cl2, ccl4 |
@@ -1,2 +0,4 @@ | ||
export function formatCharge(charge) { | ||
'use strict'; | ||
module.exports = function formatCharge(charge) { | ||
if (charge === 1) return '+'; | ||
@@ -6,2 +8,2 @@ if (charge > 1) return `+${charge}`; | ||
return ''; | ||
} | ||
}; |
@@ -1,11 +0,11 @@ | ||
import { | ||
isotopesObject as isotopes, | ||
elementsObject as elements, | ||
} from 'chemical-elements'; | ||
import { groupsObject as groups } from 'chemical-groups'; | ||
'use strict'; | ||
import { Kind } from '../Kind'; | ||
const elements = require('chemical-elements').elementsObject; | ||
const groups = require('chemical-groups/src/groupsObject.js'); | ||
import { getIsotopeRatioInfo } from './getIsotopeRatioInfo'; | ||
const Kind = require('../Kind'); | ||
const getIsotopeRatioInfo = require('./getIsotopeRatioInfo'); | ||
const isotopes = require('./getIsotopesObject'); | ||
/** | ||
@@ -16,3 +16,3 @@ * | ||
*/ | ||
export function getEA(parts) { | ||
module.exports = function getEA(parts) { | ||
let results = {}; | ||
@@ -76,3 +76,3 @@ for (let part of parts) { | ||
return eas; | ||
} | ||
}; | ||
@@ -79,0 +79,0 @@ function addMass(results, atom, mass) { |
@@ -1,5 +0,10 @@ | ||
import { elementsObject, elementsAndIsotopesObject } from 'chemical-elements'; | ||
'use strict'; | ||
import { Kind } from '../Kind'; | ||
const { | ||
elementsObject, | ||
elementsAndIsotopesObject, | ||
} = require('chemical-elements'); | ||
const Kind = require('../Kind'); | ||
/** | ||
@@ -10,3 +15,3 @@ * | ||
*/ | ||
export function getElements(parts) { | ||
module.exports = function getElements(parts) { | ||
const elements = []; | ||
@@ -50,3 +55,3 @@ for (const part of parts) { | ||
return elements; | ||
} | ||
}; | ||
@@ -53,0 +58,0 @@ function addElement(elements, newElement) { |
@@ -1,15 +0,15 @@ | ||
import { | ||
ELECTRON_MASS, | ||
unsaturationsObject as unsaturations, | ||
elementsAndIsotopesObject as elements, | ||
isotopesObject as isotopes, | ||
} from 'chemical-elements'; | ||
import { groupsObject as groups } from 'chemical-groups'; | ||
'use strict'; | ||
import { Kind } from '../Kind'; | ||
const { ELECTRON_MASS } = require('chemical-elements/src/constants'); | ||
const elements = require('chemical-elements/src/elementsAndIsotopesObject.js'); | ||
const unsaturations = require('chemical-elements/src/unsaturationsObject.js'); | ||
const groups = require('chemical-groups/src/groupsObject.js'); | ||
import { getIsotopeRatioInfo } from './getIsotopeRatioInfo'; | ||
import { partToAtoms } from './partToAtoms'; | ||
import { partToMF } from './partToMF'; | ||
const Kind = require('../Kind'); | ||
const getIsotopeRatioInfo = require('./getIsotopeRatioInfo'); | ||
const isotopes = require('./getIsotopesObject'); | ||
const partToAtoms = require('./partToAtoms'); | ||
const partToMF = require('./partToMF'); | ||
/** | ||
@@ -20,3 +20,3 @@ * | ||
*/ | ||
export function getInfo(parts, options = {}) { | ||
module.exports = function getInfo(parts, options = {}) { | ||
let { customUnsaturations = {} } = options; | ||
@@ -43,3 +43,3 @@ if (parts.length === 0) return {}; | ||
return result; | ||
} | ||
}; | ||
@@ -46,0 +46,0 @@ function getProcessedPart(part, customUnsaturations) { |
@@ -1,4 +0,6 @@ | ||
import { elementsAndStableIsotopesObject as elements } from 'chemical-elements'; | ||
'use strict'; | ||
export function getIsotopeRatioInfo(value) { | ||
const elements = require('chemical-elements').elementsAndStableIsotopesObject; | ||
function getIsotopeRatioInfo(value) { | ||
let result = { mass: 0, monoisotopicMass: 0 }; | ||
@@ -28,1 +30,3 @@ let element = elements[value.atom]; | ||
} | ||
module.exports = getIsotopeRatioInfo; |
@@ -1,8 +0,9 @@ | ||
import { | ||
elementsAndStableIsotopesObject as elements, | ||
isotopesObject as isotopes, | ||
} from 'chemical-elements'; | ||
'use strict'; | ||
import { Kind } from '../Kind'; | ||
const elements = require('chemical-elements/src/elementsAndStableIsotopesObject.js'); | ||
const Kind = require('../Kind'); | ||
const isotopes = require('./getIsotopesObject'); | ||
/** | ||
@@ -13,3 +14,3 @@ * | ||
*/ | ||
export function getIsotopesInfo(parts) { | ||
module.exports = function getIsotopesInfo(parts) { | ||
if (parts.length === 0) return []; | ||
@@ -21,3 +22,3 @@ if (parts.length > 1) { | ||
return getProcessedPart(parts[0]); | ||
} | ||
}; | ||
@@ -24,0 +25,0 @@ function getProcessedPart(part) { |
@@ -0,1 +1,3 @@ | ||
'use strict'; | ||
/** | ||
@@ -7,3 +9,3 @@ * Parse a string to extract the charge | ||
export function parseCharge(charge) { | ||
module.exports = function parseCharge(charge) { | ||
charge = charge.replace(/[()]/g, ''); | ||
@@ -24,2 +26,2 @@ let chargeNumber = 0; | ||
return chargeNumber; | ||
} | ||
}; |
@@ -1,4 +0,6 @@ | ||
import { Kind } from '../Kind'; | ||
'use strict'; | ||
import { toDisplay } from './toDisplay.js'; | ||
const Kind = require('../Kind'); | ||
const toDisplay = require('./toDisplay'); | ||
/** | ||
@@ -9,3 +11,3 @@ * Converts an array of mf elements to an array of formatting information | ||
export function partsToDisplay(parts) { | ||
module.exports = function partsToDisplay(parts) { | ||
let lines = []; | ||
@@ -26,2 +28,2 @@ for (let part of parts) { | ||
return toDisplay(lines); | ||
} | ||
}; |
@@ -1,4 +0,6 @@ | ||
import { partToMF } from './partToMF'; | ||
'use strict'; | ||
export function partsToMF(parts, options) { | ||
const partToMF = require('./partToMF'); | ||
module.exports = function partsToMF(parts, options) { | ||
let mf = []; | ||
@@ -9,2 +11,2 @@ for (let part of parts) { | ||
return mf.join(' . '); | ||
} | ||
}; |
@@ -1,3 +0,5 @@ | ||
import { Kind } from '../Kind.js'; | ||
'use strict'; | ||
const Kind = require('../Kind'); | ||
/** | ||
@@ -9,3 +11,3 @@ * Convert a MF part to an array of atoms | ||
export function partToAtoms(part) { | ||
module.exports = function partToAtoms(part) { | ||
let atoms = {}; | ||
@@ -35,2 +37,2 @@ for (let line of part) { | ||
return atoms; | ||
} | ||
}; |
@@ -1,4 +0,6 @@ | ||
import { Kind } from '../Kind'; | ||
'use strict'; | ||
export function partToMF(part, options = {}) { | ||
const Kind = require('../Kind'); | ||
module.exports = function partToMF(part, options = {}) { | ||
let mf = []; | ||
@@ -38,2 +40,2 @@ for (let line of part) { | ||
return mf.join(''); | ||
} | ||
}; |
@@ -1,2 +0,4 @@ | ||
export const superscript = { | ||
'use strict'; | ||
const superscript = { | ||
0: '⁰', | ||
@@ -22,3 +24,3 @@ 1: '¹', | ||
export const subscript = { | ||
const subscript = { | ||
0: '₀', | ||
@@ -41,1 +43,6 @@ 1: '₁', | ||
}; | ||
module.exports = { | ||
superscript, | ||
subscript, | ||
}; |
@@ -1,12 +0,14 @@ | ||
import { Format } from '../Format'; | ||
import { Kind } from '../Kind'; | ||
'use strict'; | ||
import { formatCharge } from './formatCharge.js'; | ||
const Format = require('../Format'); | ||
const Kind = require('../Kind'); | ||
const formatCharge = require('./formatCharge'); | ||
/** | ||
* Converts an array of mf elements to an array of formatting information | ||
* @param {object[]} lines of the parse method | ||
* @param {Array<Object>} result of the parse method | ||
*/ | ||
export function toDisplay(lines) { | ||
module.exports = function convertForDisplay(lines) { | ||
let results = []; | ||
@@ -101,2 +103,2 @@ let result = {}; | ||
return results; | ||
} | ||
}; |
@@ -1,5 +0,7 @@ | ||
import { Format } from '../Format'; | ||
import { Style } from '../Style'; | ||
'use strict'; | ||
export function toHtml(lines) { | ||
const Format = require('../Format'); | ||
const Style = require('../Style'); | ||
module.exports = function toHtml(lines) { | ||
let html = []; | ||
@@ -29,2 +31,2 @@ for (let line of lines) { | ||
return html.join(''); | ||
} | ||
}; |
@@ -1,6 +0,8 @@ | ||
import { atomSorter } from 'atom-sorter'; | ||
import { groupsObject } from 'chemical-groups'; | ||
'use strict'; | ||
import { Kind } from '../Kind'; | ||
const atomSorter = require('atom-sorter'); | ||
const groups = require('chemical-groups/src/groupsObject.js'); | ||
const Kind = require('../Kind'); | ||
/** | ||
@@ -10,7 +12,7 @@ * | ||
* @param {object} [options={}] | ||
* @param {boolean} [options.expand=true] - Should we expand the groupsObject | ||
* @param {boolean} [options.expand=true] - Should we expand the groups | ||
*/ | ||
export function toParts(lines, options = {}) { | ||
const { expand: shouldExpandgroupsObject = true } = options; | ||
module.exports = function toParts(lines, options = {}) { | ||
const { expand: shouldExpandGroups = true } = options; | ||
let parts = []; | ||
@@ -26,3 +28,3 @@ let currentPart = createNewPart(); | ||
case Kind.CHARGE: | ||
currentPart.lines.push({ ...line, multiplier: 1 }); | ||
currentPart.lines.push(Object.assign({}, line, { multiplier: 1 })); | ||
break; | ||
@@ -58,5 +60,5 @@ case Kind.OPENING_PARENTHESIS: | ||
globalPartMultiplier(currentPart); | ||
if (shouldExpandgroupsObject) expandgroupsObject(parts); | ||
if (shouldExpandGroups) expandGroups(parts); | ||
return combineAtomsIsotopesCharges(parts); | ||
} | ||
}; | ||
@@ -119,3 +121,3 @@ function createNewPart() { | ||
function expandgroupsObject(parts) { | ||
function expandGroups(parts) { | ||
for (let part of parts) { | ||
@@ -126,3 +128,3 @@ let expanded = false; | ||
if (line.kind === Kind.ATOM) { | ||
let group = groupsObject[line.value]; | ||
let group = groups[line.value]; | ||
@@ -173,6 +175,8 @@ if (group) { | ||
} | ||
} else if (currentKey !== key.key) { | ||
result.push(key.value); | ||
} else { | ||
result[result.length - 1].multiplier += key.value.multiplier; | ||
if (currentKey !== key.key) { | ||
result.push(key.value); | ||
} else { | ||
result[result.length - 1].multiplier += key.value.multiplier; | ||
} | ||
} | ||
@@ -179,0 +183,0 @@ currentKey = key.key; |
@@ -1,6 +0,8 @@ | ||
import { Format } from '../Format'; | ||
'use strict'; | ||
import { superscript, subscript } from './subSuperscript'; | ||
const Format = require('../Format'); | ||
export function toText(lines) { | ||
const { superscript, subscript } = require('./subSuperscript'); | ||
module.exports = function toText(lines) { | ||
let text = []; | ||
@@ -60,2 +62,2 @@ for (let line of lines) { | ||
return text.join(''); | ||
} | ||
}; |
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
3
71754
40
2385
- Removedmf-utilities@^1.4.2
- Removedmf-parser@1.5.0(transitive)
- Removedmf-utilities@1.5.0(transitive)
Updatedatom-sorter@^1.2.0
Updatedchemical-elements@^1.3.0
Updatedchemical-groups@^1.3.0