removed use of js Set

This commit is contained in:
Tim
2024-04-12 18:14:42 -04:00
parent 0084847d82
commit 71015656cd
2 changed files with 14 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
import {invokeCallback, mixin} from "@/common.js";
import {chart, createShape, deleteShapeId, dragging, draggingShapeIds, drawShape, widget} from "@/charts/chart.js";
import {unique} from "@/misc.js";
//
@@ -263,7 +264,8 @@ function dirtyKeys(propsA, propsB) {
return propsA === null ? [] : [...Object.keys(propsA)]
if (propsA===null)
return [...Object.keys(propsB)]
return [...(new Set(Object.keys(propsB)).union(new Set(Object.keys(propsA))))].filter((k)=> !(k in propsA) || propsA[k] !== propsB[k])
const keys = unique([...Object.keys(propsA), ...Object.keys(propsB)])
return keys.filter((k)=> !(k in propsA) || propsA[k] !== propsB[k])
}

View File

@@ -218,3 +218,14 @@ export function lineColor(buy, index) {
return c.string()
}
export function unique(arr) {
const u = {}, a = [];
for(let i = 0, l = arr.length; i < l; ++i){
if(!u.hasOwnProperty(arr[i])) {
a.push(arr[i]);
u[arr[i]] = 1;
}
}
return a;
}