Skip to content

Commit

Permalink
fix: put back compatibility with node 12
Browse files Browse the repository at this point in the history
  • Loading branch information
lpatiny committed May 4, 2022
1 parent 3e25498 commit a4bd8c6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs-ts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ jobs:
# Documentation: https://github.com/zakodium/workflows#nodejs-ci
uses: zakodium/workflows/.github/workflows/nodejs.yml@nodejs-v1
with:
node-version-matrix: '[14, 16, 18]'
node-version-matrix: '[12, 14, 16, 18]'
lint-check-types: true
2 changes: 1 addition & 1 deletion src/__tests__/oneShape.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('One Shape tested', () => {
},
]);

expect(result.peaks[0].shape?.fwhm).toBeCloseTo(0.31, 4);
expect(result.peaks[0].shape.fwhm).toBeCloseTo(0.31, 4);
expect(result.peaks[0].x).toBeCloseTo(0, 5);
expect(result.peaks[0].y).toBeCloseTo(0.001, 5);

Expand Down
10 changes: 8 additions & 2 deletions src/util/internalPeaks/getInternalPeaks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ export function getInternalPeaks(
for (let parameter of parameters) {
for (let property of properties) {
// check if the property is specified in the peak
let propertyValue = peak.parameters?.[parameter]?.[property];
let propertyValue =
peak.parameters &&
peak.parameters[parameter] &&
peak.parameters[parameter][property];
if (propertyValue) {
propertyValue = getNormalizedValue(
propertyValue,
Expand All @@ -67,7 +70,10 @@ export function getInternalPeaks(
}
// check if there are some global option, it could be a number or a callback

let generalParameterValue = options.parameters?.[parameter]?.[property];
let generalParameterValue =
options.parameters &&
options.parameters[parameter] &&
options.parameters[parameter][property];
if (generalParameterValue) {
if (typeof generalParameterValue === 'number') {
generalParameterValue = getNormalizedValue(
Expand Down

1 comment on commit a4bd8c6

@targos
Copy link
Member

@targos targos commented on a4bd8c6 May 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Node 12 is dead.

Please sign in to comment.