Skip to content

coderaiser/skipfirst

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Skipfirst

Skip first time condition are true and call function next time.

Install

With npm:

npm i skipfirst --save

or with bower:

bower i skipfirst --save

How to use?

var skipfirst   = require('skipfirst'),
    skip        = skipfirst(function(identifier) {
        console.log('first was skiped:', identifier);
    });

/* 
 * first <enter> key press would be skiped 
 * and called next time
 *
 * clear times when <escape> pressed.
 */
window.addEventListener('keydown', function(event) {
    var key         = event.keyCode,
        identifier  = event.keyIdentifier || event.key,
        ENTER       = 13,
        ESC         = 27;
    
    if (key === ESC)
        skip.clear();
    else
        skip(key === ENTER, identifier);
});

License

MIT

About

Skip first time condition are true and call function next time.

Resources

License

Stars

Watchers

Forks

Packages

No packages published