GithubHelp home page GithubHelp logo

joshstrobl / simpletimer Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 164 KB

SimpleTimer is a lightweight Javascript timer "framework" written in Typescript.

License: Apache License 2.0

Shell 38.54% TypeScript 61.46%

simpletimer's Introduction

SimpleTimer

About

SimpleTimer is a lightweight (as in 2kb compressed) Javascript timer "framework" written in Typescript that abstracts setInterval and setTimeout functionality. SimpleTimer allows you to:

  1. Create autostarting or non-autostarting timers.
  2. Have a timer that runs only once.
  3. Start, pause, stop your timer on the fly

Download

You can download the files, run the test(s), etc.

License

SimpleTimer is licensed under the Apache v2 License.

How can I help?

Buy me a beer

Beer in Finland isn't really cheap. No really, the Finnish government has a rather high tax on alcohol. Want features? (not really sure what...but I welcome ideas) Feel free to buy me a beer. You can use Gumroad to pitch in a couple dollars. You won't really get anything special in return, except my thanks.

Other ways

File bug reports, post a discussion, share it on social networks. You can add me on Google+ or follow me on Twitter.

Using SimpleTimer

The following options are available when defining / creating a timer:

"action" : Function (required) - The function that is executed per timer tick
"autostart" Boolean (not required, defaults to false) - Whether to autostart the timer or not
"duration" : Number (required) - The delay per tick in milliseconds
"once" : Boolean (not required, defaults to false) - Run the timer once

Example Timer construction:

var iLikeBacon = new SimpleTimer(
    {
        "action" : function(){
            console.log("I like bacon!");
        },
        "autostart" : true,
        "duration" : 5000
    }
);

In the timer above, we are executing an action every 5 seconds (5000ms) on a new SimpleTimer that has autostarted.

Properties

Only one property so far:

timerActive : Boolean - Is the timer active

Methods

start() - Start the timer
pause() - Pause the timer
restart() - Restart the timer
stop() - Stop the timer

simpletimer's People

Contributors

joshstrobl avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.