Converts an array to an object where the keys are the array entries and the values are customizable in a function.
npm install --save array-to-object-keys@^1.3.7yarn add array-to-object-keys@^1.3.7
(if configured properly)
npm install --save @jaid/array-to-object-keys@^1.3.7import arrayToObjectKeys from "array-to-object-keys"
const array = ["a", "b"]
const result = arrayToObjectKeys(array, (key, index) => {
return `#${index} - ${key}`
})Variable result will be:
{
a: "#0 - a",
b: "#1 - b",
}Setting up:
git clone [email protected]:jaid/array-to-object-keys.git
cd array-to-object-keys
npm installTesting:
npm run test:devTesting in production environment:
npm run testMIT License
Copyright © 2020, Jaid [email protected] (github.com/jaid)