wooden-ladder
v1.1.7
Published
🔨 Invokes 'fn1' until 'limit' is reached after that call 'fn2'
Downloads
145
Maintainers
Readme
wooden-ladder
🔨 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