0.1.7 • Published 3 months ago

@betgames/bg-countdown v0.1.7

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
3 months ago

TESTS

  • Run yarn test in command line to run tests

USAGE

  • In the root directory index.js exposes public API
  • Webpack must be configured in your project
  • First, need to call setup once at app start to be setup unit duration units:

    import { setup } from '@betgames/bg-countdown';
    
    setup([
        'years',
        'months',
        'weeks',
        'days',
        'hours',
        'minutes',
        'seconds',
    ]);
  • For usage simply import the timer: import { createTimer } from '@betgames/bg-countdown';

  • To import interfaces: import { ITimerOptions, ITimerInstance } from '@betgames/bg-countdown';

API

createTimer(options)

interface ITimerOptions {
    until: number;
    format?: string | Record<number, string>;
    onTick?: (timeString: string, secondsLeft: number) => void;
    onFinish?(): void;
    onAfterExactSecond?: {
        second: number;
        callback: {
            (): void;
            called?: boolean;
        };
    };
    showDurationUnits?: boolean;
}

Timer instance

interface ITimerUpdateOptions {
    until?: number;
    onFinish?(): void;
}

interface ITimerInstance {
    stop(): void;
    update(options: ITimerUpdateOptions): void;
}

format

Parameter format can be used as string, e.g.: HMS, or object: { 60: 'HM', 0: 'S' }, which means: "show hours and minutes until countdown reaces 60 seconds, then show seconds until reaches 0 seconds".

Supported format values: Y (year), O (month), D (day), H (hour), M (minute), S (second), also lowercase letters.

bashowDurationUnits

If parameter bashowDurationUnits value is set to true, then units for each period are displayed: e.g.: 1h 5min 30s, 6h 20min, 25s.

0.1.7

3 months ago

0.1.6

3 months ago

0.0.20

2 years ago

0.0.21

2 years ago

0.0.22

2 years ago

0.0.23

2 years ago

0.0.24

2 years ago

0.0.25

2 years ago

0.0.15

2 years ago

0.0.16

2 years ago

0.0.17

2 years ago

0.0.19

2 years ago

0.0.30

2 years ago

0.0.31

2 years ago

0.0.32

2 years ago

0.0.12

2 years ago

0.0.13

2 years ago

0.0.14

2 years ago

0.1.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.0.26

2 years ago

0.0.27

2 years ago

0.0.28

2 years ago

0.0.29

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.5

2 years ago

0.0.10

2 years ago

0.0.11

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.5

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago