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.5 to 1.1.6

1

build/hook/useTimer.d.ts

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

setDirection: (direction: Direction) => void;
setLastUnit: (lastUnit: Unit) => void;
setCheckpoints: (checkpoints: import("../types").Checkpoint[]) => void;

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

6

build/hook/useTimer.js

@@ -22,3 +22,3 @@ "use strict";

var _b = _a === void 0 ? {} : _a, _c = _b.initialTime, initialTime = _c === void 0 ? 0 : _c, _d = _b.direction, direction = _d === void 0 ? "forward" : _d, _e = _b.timeToUpdate, timeToUpdate = _e === void 0 ? 1000 : _e, _f = _b.startImmediately, startImmediately = _f === void 0 ? true : _f, _g = _b.lastUnit, lastUnit = _g === void 0 ? "d" : _g, _h = _b.checkpoints, checkpoints = _h === void 0 ? [] : _h, onStart = _b.onStart, onResume = _b.onResume, onPause = _b.onPause, onStop = _b.onStop, onReset = _b.onReset;
var _j = react_1.useState(__assign({}, getTimeParts_1.default(initialTime, lastUnit), { state: 'INITED' })), timerValues = _j[0], setTimerValues = _j[1];
var _j = react_1.useState(__assign({}, getTimeParts_1.default(initialTime < 0 ? 0 : initialTime, lastUnit), { state: 'INITED' })), timerValues = _j[0], setTimerValues = _j[1];
var timer = react_1.useMemo(function () {

@@ -40,2 +40,3 @@ return new TimerModel_1.TimerModel({

var setDirection = react_1.useCallback(function (direction) { return timer.setDirection(direction); }, [timer]);
var setLastUnit = react_1.useCallback(function (lastUnit) { return timer.setLastUnit(lastUnit); }, [timer]);
var setCheckpoints = react_1.useCallback(function (checkpoints) { return timer.setCheckpoints(checkpoints); }, [timer]);

@@ -57,6 +58,7 @@ var start = react_1.useCallback(function () { timer.start(); onStart && onStart(); }, [timer, onStart]);

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

@@ -63,0 +65,0 @@ react_1.useEffect(function () {

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

@@ -27,2 +26,3 @@ private direction;

setDirection(direction: any): void;
setLastUnit(lastUnit: Unit): void;
setCheckpoints(checkpoints: any): void;

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

@@ -11,3 +11,2 @@ "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;

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

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

@@ -51,2 +49,5 @@ };

};
TimerModel.prototype.setLastUnit = function (lastUnit) {
this.lastUnit = lastUnit;
};
TimerModel.prototype.setCheckpoints = function (checkpoints) {

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

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

@@ -108,12 +105,8 @@ 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 + delta;
this.internalTime = currentInternalTime;
this.time = this.time + this.timeToUpdate;
return this.time;
case 'backward': {
this.time = this.time - delta;
this.internalTime = currentInternalTime;
this.time = this.time - this.timeToUpdate;
if (this.time < 0) {

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

{
"name": "react-compound-timer",
"version": "1.1.5",
"version": "1.1.6",
"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