Skip to content

Commit 127349c

Browse files
authored
Merge pull request #28 from SanjayBoricha/add-for-in-range-func
Added for_in_range function
2 parents 99cbfeb + 6d20dcb commit 127349c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,18 @@ function find_key_and_update(arr, parent_key, parent_value, target_key, target_v
485485
return arr;
486486
}
487487

488+
/**
489+
* For in range loop like python
490+
*
491+
* @param integer num
492+
* @param function callback
493+
*/
494+
function for_in_range(num, callback) {
495+
for (let i = 0; i < num; i++) {
496+
callback(i)
497+
}
498+
}
499+
488500
/**
489501
* Group by key in array of object
490502
*
@@ -527,5 +539,6 @@ export {
527539
get_rms_value,
528540
find_key_and_update,
529541
find_and_update,
542+
for_in_range,
530543
group_by,
531544
};

0 commit comments

Comments
 (0)