From f521ec2c87324b142d60a58c095b9679f3e39b9e Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Wed, 12 Jun 2024 20:08:20 +0530 Subject: [PATCH] feat: array to object utility --- mx-interpreter/utils/utils.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 mx-interpreter/utils/utils.ts diff --git a/mx-interpreter/utils/utils.ts b/mx-interpreter/utils/utils.ts new file mode 100644 index 00000000..48883dcf --- /dev/null +++ b/mx-interpreter/utils/utils.ts @@ -0,0 +1,13 @@ +/** + * ESLint rule in case there is only one util function + * (it still does not represent the "utils" file) +*/ + +/* eslint-disable import/prefer-default-export */ + +/** + * Converts an array of scalars to an object with **items** of the array **for keys**. + */ +export function arrayToObject(array : any[]) { + return array.reduce((p, x) => ({ ...p, [x]: [] }), {}); + } \ No newline at end of file