3.1.0 • Published 8 years ago

util-time v3.1.0

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

A simple, lightweight library for facilitate work with time in JavaScript.

Note:

  • Library wrote on TypeScript and include in self declaration file.
  • Main file (i.e. index.js) use modular system CommonJS.

Including util-time

Browser

Module for browser is located in folder dist.

<script src="node_modules/util-time/dist/util-time.js"></script>

Node.js

Install from npm as dependence:

npm i util-time --save

Importing...

import * as time from 'util-time';

How to use?

import * as time from 'util-time';

/**
 * Create timer/interval. Each instance of class is separeted
 * timer or interval (independend from class). 
 */
let timer = new time.Timer(),
    interval = new time.Interval();

/**
 * To launch timer/interval necessary call method start
 * from instance.
 */
timer.start(1000, () => console.log('Hello world!'));
// ...
interval.start(1000, iter => console.log(iter));

/**
 * To reset timer/interval necessary call method reset from instance
 */
timer.reset();
// ...
interval.reset();

/**
 * You can also pause/continue.
 */
timer.pause();
// ...
timer.continue();

/**
 * Pause can be set for a specific time.
 */
interval.pause(1000);

/**
 * You can add time to timer or add iteraions to interval.
 */
timer.add(2000);
// ...
interval.add(10);

/**
 * Also reduce...
 */
timer.reduce(2000);
// ...
interval.reduce(10);

Documentation

Detail you can read in documentation

3.1.0

8 years ago

3.0.5

8 years ago

3.0.4

8 years ago

3.0.3

8 years ago

3.0.2

8 years ago

3.0.1

8 years ago

3.0.0

8 years ago

2.0.0

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago