Skip to content

Commit

Permalink
Merge pull request #277 from girder/avoid-regex-look-behind
Browse files Browse the repository at this point in the history
Avoid regex look-behind
  • Loading branch information
manthey authored Feb 9, 2023
2 parents 6bf3f49 + cfc3521 commit 8aa5f38
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions web/shapeworks/src/charts.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// functions for generating analysis charts

export type lineChartProps = {
title: string,
x_label: string,
y_label: string,
x: Array<number>,
y: Array<number>
export type lineChartProps = {
title: string,
x_label: string,
y_label: string,
x: Array<number>,
y: Array<number>
}

export function lineChartOptions (data: lineChartProps) {
Expand Down Expand Up @@ -127,7 +127,9 @@ function copyData(text: string) {

function getDownloadURL(text: string) {
const csvstring = getTextAsCSV(text);
const csvarray = csvstring.split(/(?<=\n)/gi); // uses positive look-behind to keep \n intact after split
// const csvarray = csvstring.split(/(?<=\n)/gi); // uses positive look-behind to keep \n intact after split
// this should do the same thing without the look-behind
const csvarray = csvstring.split(/\n/g).map((v, idx) => idx ? v + '\n' : v);

const blob = new Blob(csvarray);

Expand All @@ -146,7 +148,7 @@ function getTextAsCSV(text: string) {
splitstring[rowindex] = h.join(',');
}
})

return splitstring.join('\n');
}

Expand Down Expand Up @@ -176,7 +178,7 @@ function showData(data: lineChartProps) {

csvtext += `${data.x[i]},${data.y[i]}\n`
}

const div = document.createElement('div');
div.className = "dataview";

Expand Down Expand Up @@ -209,4 +211,3 @@ function roundTo(num: number, place: number) {
const factor = 10 ** place;
return Math.round(num * factor) / factor;
}

0 comments on commit 8aa5f38

Please sign in to comment.