*Add utility function ensureUniqueRecords to ensure there are no duplicate records

This commit is contained in:
Derrick Hammer 2022-08-29 00:55:53 -04:00
parent 07dcd78261
commit c0b6384fa5
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 6 additions and 0 deletions

View File

@ -61,3 +61,9 @@ export function isPromise(obj: Promise<any>) {
typeof obj.then === "function" typeof obj.then === "function"
); );
} }
export function ensureUniqueRecords(records: DNSRecord[]) {
return [
...new Set(records.map((item: DNSRecord) => JSON.stringify(item))),
].map((item) => JSON.parse(item));
}