From 40d2546b36f93267bfb99b80824075f289a87eae Mon Sep 17 00:00:00 2001 From: chris Date: Mon, 21 Apr 2025 13:34:22 +0200 Subject: [PATCH] MINOR,FEAT: to execute funciton on an array or a single value --- src/context/generalHelpers.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/context/generalHelpers.js b/src/context/generalHelpers.js index 3bd9728..08b955e 100644 --- a/src/context/generalHelpers.js +++ b/src/context/generalHelpers.js @@ -60,6 +60,19 @@ class ObjectAccessObject { } +/** + * + * @param {Object | Array} singleOrArray + * @param {Function} fun + * @returns {Object | Array} + */ +function onSingleOrArray(singleOrArray, fun){ + if(singleOrArray instanceof Array){ + return singleOrArray.map(fun); + } + return fun(singleOrArray); +} + /** *