0.5.2 • Published 10 years ago

tmg v0.5.2

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

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

0.5.2

10 years ago

0.5.1

10 years ago

0.5.0

10 years ago

0.4.1

10 years ago

0.4.0

10 years ago

0.3.0

10 years ago

0.2.0

10 years ago

0.1.0

10 years ago