Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

brukerconverter

Package Overview
Dependencies
Maintainers
6
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

brukerconverter - npm Package Compare versions

Comparing version 6.2.4-pre.1694336922 to 6.3.0

110

lib/index.js

@@ -217,19 +217,2 @@ 'use strict';

function getValueFct(results) {
const getIndex = getIndexFct(results);
return (name) => {
const index = getIndex(name);
if (index > 0 && results[index].status === 'fulfilled') {
return results[index].value;
}
};
}
function getIndexFct(results) {
return (name) => {
const index = results.findIndex((r) => r.value === name);
return index > -1 ? index + 1 : null;
};
}
function joinInfoMeta(target, toAppend) {

@@ -443,45 +426,43 @@ for (let key in toAppend.meta) {

async function convert1D(files, options) {
const data = {};
const promises = [];
promises.push('procs', parseData(files.procs, options));
promises.push('acqus', parseData(files.acqus, options));
const filesToRead = files['1r'] || files['1i'] ? ['1r', '1i'] : ['fid'];
for (const key of filesToRead) {
if (!files[key]) continue;
promises.push(files[key].arrayBuffer().then((r) => (data[key] = r)));
}
promises.push(parseData(files.procs, options).then((r) => (data.procs = r)));
promises.push(parseData(files.acqus, options).then((r) => (data.acqus = r)));
if (files.quantFactorSample) {
promises.push('ereticFactor', getEreticFactor(files));
promises.push(getEreticFactor(files).then((r) => (data.ereticFactor = r)));
}
if (files.integrals) {
promises.push('integrals', parseIntegrals(files));
promises.push(parseIntegrals(files).then((r) => (data.integrals = r)));
}
const filesToRead = files['1r'] || files['1i'] ? ['1r', '1i'] : ['fid'];
for (const key of filesToRead) {
if (!files[key]) continue;
promises.push(key, files[key].arrayBuffer());
}
return Promise.allSettled(promises).then(formatSpectrum$1);
await Promise.allSettled(promises);
return formatSpectrum$1(data);
}
function formatSpectrum$1(results) {
const getValue = getValueFct(results);
function formatSpectrum$1(data) {
const { procs: result, acqus, integrals, ereticFactor } = data;
joinInfoMeta(result, acqus);
const result = getValue('procs');
joinInfoMeta(result, getValue('acqus'));
const getIndex = getIndexFct(results);
if (getIndex('integrals')) {
result.integrals = getValue('integrals');
if (integrals) {
result.integrals = integrals;
}
if (getIndex('ereticFactor')) {
result.info.ereticFactor = getValue('ereticFactor');
if (ereticFactor) {
result.info.ereticFactor = ereticFactor;
}
if (getIndex('1r') || getIndex('1i')) {
if (data['1r'] || data['1i']) {
setProcessedSpectrumData(
{
re: getValue('1r'),
im: getValue('1i'),
re: data['1r'],
im: data['1i'],
},
result,
);
} else if (getIndex('fid')) {
setFIDSpectrumData(getValue('fid'), result);
} else if (data.fid) {
setFIDSpectrumData(data.fid, result);
}

@@ -514,24 +495,25 @@

async function convert2D(files, options) {
const data = {};
const promises = [];
promises.push('procs', parseData(files.procs, options));
promises.push('proc2s', parseData(files.proc2s, options));
promises.push('acqus', parseData(files.acqus, options));
promises.push('acqu2s', parseData(files.acqu2s, options));
const filesToRead = ['2rr', '2ri', '2ir', '2ii', 'ser'];
for (const key of filesToRead) {
if (!files[key]) continue;
promises.push(key, files[key].arrayBuffer());
promises.push(files[key].arrayBuffer().then((r) => (data[key] = r)));
}
return Promise.allSettled(promises).then(formatSpectrum);
promises.push(parseData(files.procs, options).then((r) => (data.procs = r)));
promises.push(
parseData(files.proc2s, options).then((r) => (data.proc2s = r)),
);
promises.push(parseData(files.acqus, options).then((r) => (data.acqus = r)));
promises.push(
parseData(files.acqu2s, options).then((r) => (data.acqu2s = r)),
);
await Promise.allSettled(promises);
return formatSpectrum(data);
}
function formatSpectrum(results) {
const getIndex = getIndexFct(results);
const getValue = getValueFct(results);
const result = mergeMetadata(getValue('procs'), getValue('proc2s'));
function formatSpectrum(data) {
const result = mergeMetadata(data.procs, data.proc2s);
const acqus = mergeMetadata(data.acqus, data.acqu2s);
const acqus = mergeMetadata(getValue('acqus'), getValue('acqu2s'));
joinInfoMeta(result, acqus);

@@ -547,3 +529,3 @@

const isFft = ['2rr', '2ri', '2ir', '2ii'].some((key) => getIndex(key) > 0);
const isFft = ['2rr', '2ri', '2ir', '2ii'].some((key) => key in data);
result.meta.nbSubSpectra = isFft

@@ -565,10 +547,10 @@ ? parseInt(result.meta.SI[1], 10)

{
rr: getValue('2rr'),
ri: getValue('2ri'),
ir: getValue('2ir'),
ii: getValue('2ii'),
rr: data['2rr'],
ri: data['2ri'],
ir: data['2ir'],
ii: data['2ii'],
},
result,
);
} else if (getIndex('ser')) {
} else if (data.ser) {
firstY = 0;

@@ -586,3 +568,3 @@ lastY = result.meta.nbSubSpectra;

yTransmitterFrequencyOffset / yTransmitterFrequency + yWindowSize / 2;
setFIDSpectrumData(getValue('ser'), result);
setFIDSpectrumData(data.ser, result);
}

@@ -589,0 +571,0 @@

{
"name": "brukerconverter",
"version": "6.2.4-pre.1694336922",
"version": "6.3.0",
"description": "Parse and convert Bruker raw data",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -1,2 +0,1 @@

import { getIndexFct, getValueFct } from './getValueFct.js';
import { joinInfoMeta } from './joinMetaInfo.js';

@@ -9,45 +8,43 @@ import { parseData } from './parseData';

export async function convert1D(files, options) {
const data = {};
const promises = [];
promises.push('procs', parseData(files.procs, options));
promises.push('acqus', parseData(files.acqus, options));
const filesToRead = files['1r'] || files['1i'] ? ['1r', '1i'] : ['fid'];
for (const key of filesToRead) {
if (!files[key]) continue;
promises.push(files[key].arrayBuffer().then((r) => (data[key] = r)));
}
promises.push(parseData(files.procs, options).then((r) => (data.procs = r)));
promises.push(parseData(files.acqus, options).then((r) => (data.acqus = r)));
if (files.quantFactorSample) {
promises.push('ereticFactor', getEreticFactor(files));
promises.push(getEreticFactor(files).then((r) => (data.ereticFactor = r)));
}
if (files.integrals) {
promises.push('integrals', parseIntegrals(files));
promises.push(parseIntegrals(files).then((r) => (data.integrals = r)));
}
const filesToRead = files['1r'] || files['1i'] ? ['1r', '1i'] : ['fid'];
for (const key of filesToRead) {
if (!files[key]) continue;
promises.push(key, files[key].arrayBuffer());
}
return Promise.allSettled(promises).then(formatSpectrum);
await Promise.allSettled(promises);
return formatSpectrum(data);
}
function formatSpectrum(results) {
const getValue = getValueFct(results);
function formatSpectrum(data) {
const { procs: result, acqus, integrals, ereticFactor } = data;
joinInfoMeta(result, acqus);
const result = getValue('procs');
joinInfoMeta(result, getValue('acqus'));
const getIndex = getIndexFct(results);
if (getIndex('integrals')) {
result.integrals = getValue('integrals');
if (integrals) {
result.integrals = integrals;
}
if (getIndex('ereticFactor')) {
result.info.ereticFactor = getValue('ereticFactor');
if (ereticFactor) {
result.info.ereticFactor = ereticFactor;
}
if (getIndex('1r') || getIndex('1i')) {
if (data['1r'] || data['1i']) {
setProcessedSpectrumData(
{
re: getValue('1r'),
im: getValue('1i'),
re: data['1r'],
im: data['1i'],
},
result,
);
} else if (getIndex('fid')) {
setFIDSpectrumData(getValue('fid'), result);
} else if (data.fid) {
setFIDSpectrumData(data.fid, result);
}

@@ -54,0 +51,0 @@

@@ -6,27 +6,27 @@ import { joinInfoMeta } from './joinMetaInfo.js';

import { setProcessedSpectrumData } from './setProcessedSpectrumData';
import { getIndexFct, getValueFct } from './getValueFct.js';
export async function convert2D(files, options) {
const data = {};
const promises = [];
promises.push('procs', parseData(files.procs, options));
promises.push('proc2s', parseData(files.proc2s, options));
promises.push('acqus', parseData(files.acqus, options));
promises.push('acqu2s', parseData(files.acqu2s, options));
const filesToRead = ['2rr', '2ri', '2ir', '2ii', 'ser'];
for (const key of filesToRead) {
if (!files[key]) continue;
promises.push(key, files[key].arrayBuffer());
promises.push(files[key].arrayBuffer().then((r) => (data[key] = r)));
}
return Promise.allSettled(promises).then(formatSpectrum);
promises.push(parseData(files.procs, options).then((r) => (data.procs = r)));
promises.push(
parseData(files.proc2s, options).then((r) => (data.proc2s = r)),
);
promises.push(parseData(files.acqus, options).then((r) => (data.acqus = r)));
promises.push(
parseData(files.acqu2s, options).then((r) => (data.acqu2s = r)),
);
await Promise.allSettled(promises);
return formatSpectrum(data);
}
function formatSpectrum(results) {
const getIndex = getIndexFct(results);
const getValue = getValueFct(results);
const result = mergeMetadata(getValue('procs'), getValue('proc2s'));
function formatSpectrum(data) {
const result = mergeMetadata(data.procs, data.proc2s);
const acqus = mergeMetadata(data.acqus, data.acqu2s);
const acqus = mergeMetadata(getValue('acqus'), getValue('acqu2s'));
joinInfoMeta(result, acqus);

@@ -42,3 +42,3 @@

const isFft = ['2rr', '2ri', '2ir', '2ii'].some((key) => getIndex(key) > 0);
const isFft = ['2rr', '2ri', '2ir', '2ii'].some((key) => key in data);
result.meta.nbSubSpectra = isFft

@@ -60,10 +60,10 @@ ? parseInt(result.meta.SI[1], 10)

{
rr: getValue('2rr'),
ri: getValue('2ri'),
ir: getValue('2ir'),
ii: getValue('2ii'),
rr: data['2rr'],
ri: data['2ri'],
ir: data['2ir'],
ii: data['2ii'],
},
result,
);
} else if (getIndex('ser')) {
} else if (data.ser) {
firstY = 0;

@@ -81,3 +81,3 @@ lastY = result.meta.nbSubSpectra;

yTransmitterFrequencyOffset / yTransmitterFrequency + yWindowSize / 2;
setFIDSpectrumData(getValue('ser'), result, true);
setFIDSpectrumData(data.ser, result, true);
}

@@ -84,0 +84,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc