2.0.0 • Published 8 years ago

loop-for-n-times v2.0.0

Weekly downloads
-
License
GPL-3.0
Repository
-
Last release
8 years ago

Summary

A looping construct for people who don't like the word "for".

Description

loop-for-n-times defines a function with the following parameters:

  • initial-value (Any): any value that you like, used to set the initial value of the looping counter.
  • compare (Function): a function that receives the current value of the looping counter and returns a Boolean true or false as it so to either continue or stop looping.
  • increment (Function): a function that receives the current value of the looping counter and returns the next value of the looping counter.
  • body (Function): a function that receives the current value of the looping counter and does whatever it wants with is.

Example:

var loop = require('loop-for-n-times'),
  n = 0;
loop(
  _ => 0,
  i => i < 10,
  i => i + 1,
  i => n += i);
console.log("n is 45: %s", n === 45);
2.0.0

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago