Skip to content

Commit 2093f05

Browse files
committed
Improved documentation
1 parent f58c6fa commit 2093f05

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"private": true,
3-
"version": "1.0.12",
3+
"version": "1.0.13",
44
"author": "Jaid <jaid.jsx@gmail.com> (https://github.com/Jaid)",
55
"babel": {
66
"presets": [

src/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
1+
/**
2+
* @typedef valueGenerator
3+
* @type {function}
4+
* @param {string} value The original array entry
5+
* @param {number} index The index of the array entry (starts at 0)
6+
* @returns {*}
7+
*/
28
/**
39
* Converts an array to an object with static keys and customizable values
410
* @example
@@ -11,7 +17,7 @@
1117
* arrayToObjectKeys(["a", "b"], (key, index) => `value for ${key} #${index + 1}`)
1218
* // {a: "value for a #1", b: "value for b #2"}
1319
* @param {string[]} array Keys for the generated object
14-
* @param {function(value, index)|*} [valueGenerator] Optional function that sets the object values based on key and index
20+
* @param {valueGenerator|*} [valueGenerator=null] Optional function that sets the object values based on key and index
1521
* @returns {Object<string, *>} A generated object based on the array input
1622
*/
1723
export default (array, valueGenerator = null) => {

0 commit comments

Comments
 (0)