This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Note: Does only work with primities (numbers, strings) as objects/arrays, etc are saved by reference | |
// meaning even if the object is the same twice, the reference will be different and Set() will not have unique true values | |
// this could maybe be fixed by JSON.stringifying non-primitive values on save | |
export function mergeDedupeArrays(arrays) { | |
let combinedArrays = [] | |
for (let array of arrays) { | |
combinedArrays = combinedArrays.concat(array) | |
} | |
return [...new Set(combinedArrays)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// based upon: | |
// https://docs.microsoft.com/en-us/dotnet/standard/base-types/how-to-extract-a-protocol-and-port-number-from-a-url | |
const url = 'http://www.google.com/fwef://gerg'; | |
const regex = /^(?<proto>\w+):/g; | |
const found = url.match(regex); | |
console.log(found); |