Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 924: add support for arrays in scientificMetadata #925

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
change tabs to spaces
jkotan committed Dec 1, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 4f29306fe61f935d306118558d3f4071b4398521
13 changes: 6 additions & 7 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
@@ -12,22 +12,21 @@ import {
} from "./interfaces/common.interface";
import { ScientificRelation } from "./scientific-relation.enum";


export const convertArrayToSI = (
sbliven marked this conversation as resolved.
Show resolved Hide resolved
inputValue: number[],
inputUnit: string,
): { valueSI: number[]; unitSI: string } => {
try {
const newUnit = unit(inputUnit).toSI().toJSON().unit;
if(inputValue && inputValue.length){
const value = Array.from(
inputValue,
(iValue) => unit(iValue, inputUnit).to(newUnit).toJSON().value
);
return { valueSI: value, unitSI: newUnit };
const value = Array.from(
inputValue,
(iValue) => unit(iValue, inputUnit).to(newUnit).toJSON().value
);
return { valueSI: value, unitSI: newUnit };
}
else {
return { valueSI: inputValue, unitSI: newUnit };
return { valueSI: inputValue, unitSI: newUnit };
}
} catch (error) {
console.error(error);