Never-ending Pumpkin Mulch

    tmg

    0.5.2 • Public • Published

    tmg Build Status

    Timer generator

    tmg-cli - CLI for this module

    Install

    npm install --save tmg

    Usage

    var tmg = require('tmg');
    var date = new Date(2018, 05, 01, 12, 0, 0);
     
    tmg(date)
      .format('h:mm:ss')
      .start(function(t) {
        t.toString();
      });

    API

    tmg([date])

    Return timer, default new Date()

    var timer = tmg();
    var countdown = tmg(new Date(2018, 05, 01, 12, 0, 0));

    .format(str)

    Set format string

    tmg().format('D [days] h:mm:ss'); // 4 days 2:00:15

    Can be used:

    • D - days
    • h, hh - hours
    • m, mm - minutes
    • s, ss - seconds
    • [escaped] - escaped text

    .start(fn)

    Start timer interval

    timer.start(function(t) {
      t.toString(); // '12:00:10'
    });

    .end()

    Clear timer interval

    .toObject([str])

    Return object with current timer value with local format str

    timer.toObject(); // {h: 12, m: 0, s: 10}
    timer.toObject('m:s'); // {m: 720, s: 10}

    .toArray([str])

    Return object with current timer value with local format str

    timer.toArray(); // [12, 0, 10]
    timer.toArray('m:s'); // [720, 10]

    .toString([str])

    Return string with current timer value with local format str

    timer.toString(); // '12:00:10'
    timer.toString('mm:ss'); // '720:10'

    License

    MIT

    Install

    npm i tmg

    DownloadsWeekly Downloads

    3

    Version

    0.5.2

    License

    MIT

    Last publish

    Collaborators

    • andrepolischuk