@sebgroup/frontend-tools
Version:
A set of frontend tools
13 lines (11 loc) • 421 B
JavaScript
/**
* Converts an array into an object
* @param array The target array
* @param keyField The key to be used as identifier for each key of the new object
* @returns {Object} The generated object
*/
function arrayToObject(array, keyField = "") {
return Object.assign({}, ...array.map((item, index) => ({ [keyField + index]: item })));
}
export { arrayToObject };
//# sourceMappingURL=arrayToObject.js.map