diff --git a/coretool.js b/coretool.js index 3275456..da18f55 100644 --- a/coretool.js +++ b/coretool.js @@ -10,6 +10,10 @@ module.exports = { sleep: (ms) => new Promise((resolve, reject) => setTimeout(resolve, ms)), + objectize_array (arr, key) { + return arr.reduce((obj, item) => ({ ...obj, [item[key]]: item }), {}) + }, + deepFreeze (obj) { if (typeof obj !== 'object' || obj === null) { return obj