Skip to content

Commit

Permalink
refactor(toolbox/getcontext): refactoring to remove iteration of a Set
Browse files Browse the repository at this point in the history
  • Loading branch information
korgon committed Nov 27, 2024
1 parent e293acc commit 2f3207e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/snap-toolbox/src/getContext/getContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ export function getContext(evaluate: string[] = [], script?: HTMLScriptElement |
const scriptInnerVars = scriptInnerHTML.match(/([a-zA-Z_$][a-zA-Z_$0-9]*)\s?=/g)?.map((match) => match.replace(/[\s=]/g, ''));

const combinedVars = evaluate.concat(scriptInnerVars || []);
const evaluateVars = [...new Set(combinedVars)]; // de-dupe

// de-dupe vars
const evaluateVars = combinedVars.filter((item, index) => {
return combinedVars.indexOf(item) === index;
});

// evaluate text and put into variables
evaluate?.forEach((name) => {
Expand Down

0 comments on commit 2f3207e

Please sign in to comment.