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 = {};