nmr-processing
Advanced tools
Comparing version 6.0.4 to 6.0.5
@@ -160,3 +160,2 @@ import { xyIntegration } from 'ml-spectra-processing'; | ||
ranges = joinRanges(ranges); | ||
// return new Ranges(ranges); | ||
return ranges; | ||
@@ -163,0 +162,0 @@ } |
export function joinRanges(ranges) { | ||
ranges.sort((a, b) => a.from - b.from); | ||
for (let i = 0; i < ranges.length - 1; i++) { | ||
if (ranges[i].to > ranges[i + 1].from) { | ||
const currentRange = ranges[i]; | ||
const nextRange = ranges[i + i]; | ||
ranges[i].to = Math.max(ranges[i + 1].to, ranges[i].to); | ||
const currentRange = ranges[i]; | ||
const nextRange = ranges[i + 1]; | ||
if (currentRange.to > nextRange.from) { | ||
currentRange.to = Math.max(nextRange.to, currentRange.to); | ||
if (currentRange.signals && nextRange.signals) { | ||
currentRange.signals = currentRange.signals.concat(nextRange.signals); | ||
} | ||
if (currentRange.integration) { | ||
if (currentRange.integration !== undefined) { | ||
currentRange.integration += nextRange.integration || 0; | ||
@@ -13,0 +13,0 @@ } |
@@ -166,3 +166,2 @@ "use strict"; | ||
ranges = (0, joinRanges_1.joinRanges)(ranges); | ||
// return new Ranges(ranges); | ||
return ranges; | ||
@@ -169,0 +168,0 @@ } |
@@ -7,10 +7,10 @@ "use strict"; | ||
for (let i = 0; i < ranges.length - 1; i++) { | ||
if (ranges[i].to > ranges[i + 1].from) { | ||
const currentRange = ranges[i]; | ||
const nextRange = ranges[i + i]; | ||
ranges[i].to = Math.max(ranges[i + 1].to, ranges[i].to); | ||
const currentRange = ranges[i]; | ||
const nextRange = ranges[i + 1]; | ||
if (currentRange.to > nextRange.from) { | ||
currentRange.to = Math.max(nextRange.to, currentRange.to); | ||
if (currentRange.signals && nextRange.signals) { | ||
currentRange.signals = currentRange.signals.concat(nextRange.signals); | ||
} | ||
if (currentRange.integration) { | ||
if (currentRange.integration !== undefined) { | ||
currentRange.integration += nextRange.integration || 0; | ||
@@ -17,0 +17,0 @@ } |
{ | ||
"name": "nmr-processing", | ||
"version": "6.0.4", | ||
"version": "6.0.5", | ||
"description": "Pure functions allowing to process NMR spectra.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -261,3 +261,2 @@ import type { DataXY } from 'cheminfo-types'; | ||
if (joinOverlapRanges) ranges = joinRanges(ranges); | ||
// return new Ranges(ranges); | ||
return ranges; | ||
@@ -264,0 +263,0 @@ } |
@@ -5,11 +5,13 @@ import type { NMRRange } from '../../xy/NMRRange'; | ||
ranges.sort((a, b) => a.from - b.from); | ||
for (let i = 0; i < ranges.length - 1; i++) { | ||
if (ranges[i].to > ranges[i + 1].from) { | ||
const currentRange = ranges[i]; | ||
const nextRange = ranges[i + i]; | ||
ranges[i].to = Math.max(ranges[i + 1].to, ranges[i].to); | ||
const currentRange = ranges[i]; | ||
const nextRange = ranges[i + 1]; | ||
if (currentRange.to > nextRange.from) { | ||
currentRange.to = Math.max(nextRange.to, currentRange.to); | ||
if (currentRange.signals && nextRange.signals) { | ||
currentRange.signals = currentRange.signals.concat(nextRange.signals); | ||
} | ||
if (currentRange.integration) { | ||
if (currentRange.integration !== undefined) { | ||
currentRange.integration += nextRange.integration || 0; | ||
@@ -21,3 +23,4 @@ } | ||
} | ||
return ranges; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
3987123
111434