Update 0BDFDB.plugin.js

This commit is contained in:
Mirco Wittrien 2021-03-06 22:53:28 +01:00
parent 0354b843fb
commit 47c55dbe05
1 changed files with 9 additions and 0 deletions

View File

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