function-looper

1.0.2 • Public • Published

This is an early version of this module. It's intended to repeat or execute a function multiple times define by the second argument, you use a third argument as an optional delay between executions. At the end it returns a promise that resolves to an array with the results of each execution. It should work with async functions as well.

const { repeat } = require("function-looper");
 
function whateverFunction(iterator) {
  return "Hello" + iterator;
}
 
repeat(whateverFunction, 6, 50000).then(console.log); //: [ 'Hello1', 'Hello2', 'Hello3', 'Hello4', 'Hello5', 'Hello6' ]

The third param is optional and defaults to 0

Package Sidebar

Install

npm i function-looper

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

1.87 kB

Total Files

3

Last publish

Collaborators

  • kervin5