From e7eaa1d4ad1c95f91d069438a9f7e6b7c71d4b42 Mon Sep 17 00:00:00 2001 From: Alex Iglesias Date: Tue, 2 Nov 2021 12:41:15 +0100 Subject: [PATCH] Created `sameValues` helper. --- helpers/index.ts | 1 + helpers/sameValues.ts | 7 +++++++ package.json | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 helpers/sameValues.ts diff --git a/helpers/index.ts b/helpers/index.ts index 64afbb9..a827cc2 100644 --- a/helpers/index.ts +++ b/helpers/index.ts @@ -13,6 +13,7 @@ export { isVisible } from './isVisible'; export { queryElement } from './queryElement'; export { removeChildElements } from './removeChildElements'; export { removeSpaces } from './removeSpaces'; +export { sameValues } from './sameValues'; export { selectInputElement } from './selectInputElement'; export { setFormFieldValue } from './setFormFieldValue'; export { simulateEvent } from './simulateEvent'; diff --git a/helpers/sameValues.ts b/helpers/sameValues.ts new file mode 100644 index 0000000..89120a5 --- /dev/null +++ b/helpers/sameValues.ts @@ -0,0 +1,7 @@ +/** + * Compares if two arrays have the same exact values. + * @param array1 + * @param array2 + */ +// prettier-ignore +export const sameValues = (array1: unknown[], array2: unknown[]): boolean => array1.every((key) => array2.includes(key)) && array2.every((key) => array1.includes(key)); diff --git a/package.json b/package.json index 0f8853f..1230ef7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@finsweet/ts-utils", - "version": "0.20.2", + "version": "0.21.0", "description": "Typescript utils for custom Webflow projects.", "main": "index.ts", "module": "index.ts",