1.1.2 • Published 11 months ago

@betgames/bg-countdown v1.1.2

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
11 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 reaches 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.

1.1.2

11 months ago

1.1.0

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.0.20

3 years ago

0.0.21

3 years ago

0.0.22

3 years ago

0.0.23

3 years ago

0.0.24

3 years ago

0.0.25

3 years ago

0.0.15

3 years ago

0.0.16

3 years ago

0.0.17

3 years ago

0.0.19

3 years ago

0.0.30

3 years ago

0.0.31

3 years ago

0.0.32

3 years ago

0.0.12

4 years ago

0.0.13

4 years ago

0.0.14

4 years ago

0.1.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.0.26

3 years ago

0.0.27

3 years ago

0.0.28

3 years ago

0.0.29

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.5

3 years ago

0.0.10

4 years ago

0.0.11

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.5

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago