We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c2864c1 commit d09fe0dCopy full SHA for d09fe0d
src/index.js
@@ -1,3 +1,15 @@
1
+/**
2
+ * Converts an array to an object with static keys and customizable values
3
+ * @example
4
+ * arrayToObjectKeys(["a", "b"])
5
+ * // {a: null, b: null}
6
7
+ * arrayToObjectKeys(["a", "b"], (key, index) => `value for ${key} #${index + 1}`)
8
+ * // {a: "value for a #1", b: "value for b #2"}
9
+ * @param {Array} array
10
+ * @param {function} function
11
+ * @returns {Object} A generated object based on the array input
12
+ */
13
export default (array, valueGenerator = null) => {
14
if (!Array.isArray(array)) {
15
return {}
0 commit comments