Skip to content

Commit

Permalink
fix: use nanoid for id generations
Browse files Browse the repository at this point in the history
  • Loading branch information
Estasie committed Dec 27, 2024
1 parent 1699c82 commit a26c10f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/YagrCore/plugins/plotLines/plotLines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {DrawOrderKey} from '../../utils/types';
import {PBandConfig} from 'src/types';
import {deepIsEqual} from '../../utils/common';
import {calculateFromTo} from './utils';
import {nanoid} from 'nanoid';

const MAX_X_SCALE_LINE_OFFSET = 0;
const DRAW_MAP = {
Expand Down Expand Up @@ -54,7 +55,7 @@ export default function plotLinesPlugin(options: PlotLineOptions): PlotLinesPlug
return line.id;
}
const lineWithoutId = Array.from(plotLines.entries()).find(([_, l]) => deepIsEqual(l, line))?.[0];
return lineWithoutId || `${Math.random()}`;
return lineWithoutId || `${nanoid()}`;
}

function renderPlotLines(u: UPlot) {
Expand Down

0 comments on commit a26c10f

Please sign in to comment.