Skip to content

Commit

Permalink
Add esdoc comments for .eachIndex() method
Browse files Browse the repository at this point in the history
  • Loading branch information
arnellebalane authored and aldnav committed Jun 1, 2019
1 parent bbd2e99 commit 1a65a31
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions methods/eachIndex/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Iterates the items of the array and passes their index to the callback.
*
* @param {Array} array
* @param {Function} callback - The function that will be passed the indeces
* of each array item.
*
* @return {Array} The original given array.
*
* @example
* eachIndex(['a', 'b', 'c'], i => console.log(i)); // prints: 0 1 2
*
* @example
* rbjs(['a', 'b', 'c']).eachIndex(i => console.log(i)); // prints: 0 1 2
*/
export default function eachIndex(array, callback) {
if (typeof callback !== 'function') {
throw new TypeError('Parameter "callback" must be a function.');
Expand Down

0 comments on commit 1a65a31

Please sign in to comment.