2.0.2 • Published 3 years ago

@pipeletteio/time-meter v2.0.2

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

Installation

npm install @pipeletteio/time-meter

Docs:

Read documentation here.

Example:

const { TimeMeter } = require('@pipeletteio/time-meter');

const meter = new TimeMeter();

setTimeout(() => console.log(`${meter.next()}ms`), 200);

With Typescript:

import { TimeMeter } from '@pipeletteio/time-meter';

const meter = new TimeMeter();

setTimeout(() => console.log(`${meter.next()}ms`), 200);

A shared time meter instance can be retreived from the package (default meter uses the milisecond format):

import { meter } from '@pipeletteio/time-meter';

Using a custom formatter (availables: LegacyFormatter, MilisecondFormatter and NanosecondFormatter):

import { TimeMeter, LegacyFormatter } from '@pipeletteio/time-meter';

const meter = new TimeMeter({ formatter: new LegacyFormatter() });

setTimeout(() => {
  const [seconds, nanoseconds] = meter.next();
  console.log(`${seconds}s ${nanoseconds}ns`);
}, 200);

Using your own formatter:

import { TimeMeter, TimeFormatterInterface } from '@pipeletteio/time-meter';

class SecondFormatter implements TimeFormatterInterface {
  static DIVIDER = BigInt(1e9);

  format (ns: bigint): number {
    return Number(ns / SecondFormatter.DIVIDER);
  }
}

const meter = new TimeMeter({ formatter: new SecondFormatter() });

setTimeout(() => console.log(`${meter.next()}s`), 1500);
2.0.2

3 years ago

2.0.0-rc.2

3 years ago

2.0.0-rc.3

3 years ago

2.0.0-rc.17

3 years ago

2.0.0-rc.4

3 years ago

2.0.0-rc.5

3 years ago

2.0.0-rc.15

3 years ago

2.0.0-rc.16

3 years ago

2.0.0-rc.13

3 years ago

2.0.0-rc.14

3 years ago

2.0.0-rc.1

3 years ago

2.0.0-rc.11

3 years ago

2.0.0-rc.12

3 years ago

2.0.0-rc.10

3 years ago

2.0.0-rc.6

3 years ago

2.0.0-rc.7

3 years ago

2.0.1

3 years ago

2.0.0-rc.8

3 years ago

2.0.0

3 years ago

2.0.0-rc.9

3 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago