@plasma-platform/clock-timer

Counter for promotions

Usage no npm install needed!

<script type="module">
  import plasmaPlatformClockTimer from 'https://cdn.skypack.dev/@plasma-platform/clock-timer';
</script>

README

version nextVersion downloads license dependency


Full documentation
install:
npm i @plasma-platform/clock-timer -S

Short documentation

Table of Contents

ClockTimer

Creates CNT1A promotion timer

ClockTimer

Creates CNT1C promotion timer

ClockTimer

clock-timer model

init

Initializes the timer

Parameters

  • args Object
    • args.locale string timer locale
    • args.count number? Quantity of ticks for 'counter' timerFace type.
    • args.timerFace string Timer type (daily | hourly | counter). 'daily' by default
    • args.timerName string Unique name for the timer
    • args.startTimeStamp number? Timer start date
    • args.endTimeStamp number Timer end date
    • args.direction string Timer count direction ('decrement' | 'increment') // TODO: implement direction behaviour

updateTimer

updates timer value(s)

Parameters

  • changedTime Object timer changed values
  • timerId number generated id to distinguish which timer to update

Returns boolean

getChangedValues

Compares new and old date and decides which values to change

Parameters

  • newTime Object new time object

Returns Object Values to be changed

init

Initializes the timer

Parameters

  • args Object
    • args.locale string timer locale
    • args.count number? Quantity of ticks for 'counter' timerFace type.
    • args.timerFace string Timer type (daily | hourly | counter). 'daily' by default
    • args.timerName string Unique name for the timer
    • args.startTimeStamp number? Timer start date
    • args.endTimeStamp number Timer end date
    • args.direction string Timer count direction ('decrement' | 'increment') // TODO: implement direction behaviour

updateTimer

updates timer value(s)

Parameters

  • changedTime Object timer changed values
  • timerId number generated id to distinguish which timer to update

Returns boolean

getChangedValues

Compares new and old date and decides which values to change

Parameters

  • newTime Object new time object

Returns Object Values to be changed

start

Start clock-timer

stop

Stops clock-timer

calculateTime

Calculates initial time

Parameters

  • intervalTime number Interval time (for setInterval function)

Returns (Object | number) 'time' object or 'count' (depends on 'timerFace' property)

tick

Function to be executed every timer tick. Calculates new time or count

Parameters

  • intervalTime number clock-timer interval in milliseconds

Returns boolean

mergeDeep

Merges objects

Parameters

  • objects Array<object> one or more objects to be merged

Returns object