From 47c55dbe0595ece89e2a2730954f4a6fc7f4848b Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Sat, 6 Mar 2021 22:53:28 +0100 Subject: [PATCH] Update 0BDFDB.plugin.js --- Library/0BDFDB.plugin.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Library/0BDFDB.plugin.js b/Library/0BDFDB.plugin.js index e369f84786..9e02b8e41e 100644 --- a/Library/0BDFDB.plugin.js +++ b/Library/0BDFDB.plugin.js @@ -283,6 +283,15 @@ module.exports = (_ => { } return newObj; }; + BDFDB.ObjectUtils.group = function (obj, key) { + if (!BDFDB.ObjectUtils.is(obj)) return {}; + if (typeof key != "string") return obj; + return Object.entries(obj).reduce((newObj, objPair) => { + if (!newObj[objPair[1][key]]) newObj[objPair[1][key]] = {}; + newObj[objPair[1][key]][objPair[0]] = objPair[1]; + return newObj; + }, {}); + }; BDFDB.ObjectUtils.reverse = function (obj, sort) { if (!BDFDB.ObjectUtils.is(obj)) return {}; let newObj = {};