Socket
Socket
Sign inDemoInstall

react-compound-timer

Package Overview
Dependencies
6
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.6 to 1.1.7

1

build/hook/useTimer.d.ts

@@ -28,2 +28,3 @@ import { Unit, Checkpoints, Direction, TimerValue } from '../types';

setLastUnit: (lastUnit: Unit) => void;
setTimeToUpdate: (interval: number) => void;
setCheckpoints: (checkpoints: import("../types").Checkpoint[]) => void;

@@ -30,0 +31,0 @@ };

4

build/hook/useTimer.js

@@ -41,2 +41,3 @@ "use strict";

var setCheckpoints = react_1.useCallback(function (checkpoints) { return timer.setCheckpoints(checkpoints); }, [timer]);
var setTimeToUpdate = react_1.useCallback(function (interval) { return timer.setTimeToUpdate(interval); }, [timer]);
var start = react_1.useCallback(function () { timer.start(); onStart && onStart(); }, [timer, onStart]);

@@ -58,6 +59,7 @@ var stop = react_1.useCallback(function () { timer.stop(); onStop && onStop(); }, [timer, onStop]);

setLastUnit: setLastUnit,
setTimeToUpdate: setTimeToUpdate,
setCheckpoints: setCheckpoints,
}); }, [
start, stop, pause, reset, resume,
setTime, getTime, getTimerState, setDirection, setLastUnit, setCheckpoints,
setTime, getTime, getTimerState, setDirection, setLastUnit, setTimeToUpdate, setCheckpoints,
]);

@@ -64,0 +66,0 @@ react_1.useEffect(function () {

import { TimeParts, Checkpoint, Direction, TimerValue, Unit } from '../../types';
export declare class TimerModel {
private initialTime;
private internalTime;
private time;

@@ -25,4 +26,5 @@ private direction;

getTime(): number;
setLastUnit(lastUnit: Unit): void;
setTimeToUpdate(interval: number): void;
setDirection(direction: any): void;
setLastUnit(lastUnit: Unit): void;
setCheckpoints(checkpoints: any): void;

@@ -29,0 +31,0 @@ start(): void;

@@ -11,2 +11,3 @@ "use strict";

var initialTime = _a.initialTime, direction = _a.direction, timeToUpdate = _a.timeToUpdate, lastUnit = _a.lastUnit, checkpoints = _a.checkpoints, onChange = _a.onChange;
this.internalTime = performance.now();
this.initialTime = initialTime;

@@ -40,2 +41,3 @@ this.time = initialTime;

TimerModel.prototype.setTime = function (time) {
this.internalTime = performance.now();
this.time = time;

@@ -46,8 +48,13 @@ };

};
TimerModel.prototype.setLastUnit = function (lastUnit) {
this.lastUnit = lastUnit;
};
TimerModel.prototype.setTimeToUpdate = function (interval) {
this.pause();
this.timeToUpdate = interval;
this.resume();
};
TimerModel.prototype.setDirection = function (direction) {
this.direction = direction;
};
TimerModel.prototype.setLastUnit = function (lastUnit) {
this.lastUnit = lastUnit;
};
TimerModel.prototype.setCheckpoints = function (checkpoints) {

@@ -83,2 +90,6 @@ this.checkpoints = checkpoints;

if (callImmediately === void 0) { callImmediately = false; }
if (this.timerId) {
clearInterval(this.timerId);
}
this.internalTime = performance.now();
var repeatedFunc = function () {

@@ -105,8 +116,12 @@ var oldTime = _this.time;

if (this.innerState.isPlaying()) {
var currentInternalTime = performance.now();
var delta = Math.abs(currentInternalTime - this.internalTime);
switch (this.direction) {
case 'forward':
this.time = this.time + this.timeToUpdate;
this.time = this.time + delta;
this.internalTime = currentInternalTime;
return this.time;
case 'backward': {
this.time = this.time - this.timeToUpdate;
this.time = this.time - delta;
this.internalTime = currentInternalTime;
if (this.time < 0) {

@@ -113,0 +128,0 @@ this.stop();

{
"name": "react-compound-timer",
"version": "1.1.6",
"version": "1.1.7",
"description": "Timer compound react component",

@@ -5,0 +5,0 @@ "main": "build",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc