wooden-ladder

Invokes 'fn1' until 'limit' is reached after that call 'fn2'

Usage no npm install needed!

<script type="module">
  import woodenLadder from 'https://cdn.skypack.dev/wooden-ladder';
</script>

README

wooden-ladder (npm)

npm version Travis Coverage Status

:hammer: Invokes "fn1" until "limit" is reached after that call "fn2".

Install

$ npm install wooden-ladder

Usage

Example 1 (only climb)

let WoodenLadder = require('wooden-ladder');

let fn1 = () => console.log(1);
let fn2 = () => console.log(2);
let lad = new WoodenLadder(3, fn1, fn2);

lad.climb(); // fired "fn1"
lad.climb(); // fired "fn1"
lad.climb(); // fired "fn1"

lad.climb(); // fired "fn2"
lad.climb(); // fired "fn2"
lad.climb(); // fired "fn2"
...
lad.climb(); // fired "fn2"

Example 2 (with reset)

let WoodenLadder = require('wooden-ladder');

let fn1 = () => console.log(1);
let fn2 = () => {
    console.log(2)
    lad.reset();
};
let lad = new WoodenLadder(3, fn1, fn2);

lad.climb(); // fired "fn1"
lad.climb(); // fired "fn1"
lad.climb(); // fired "fn1"

lad.climb(); // fired "fn2"

lad.climb(); // fired "fn1"
lad.climb(); // fired "fn1"
lad.climb(); // fired "fn1"

lad.climb(); // fired "fn2"
lad.climb(); // fired "fn2"
lad.climb(); // fired "fn2"
...
lad.climb(); // fired "fn2"

License

The MIT License @ 2016