New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

timer-countdown

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timer-countdown - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

36

lib/CountdownTimer.js

@@ -52,9 +52,8 @@ "use strict";

_classCallCheck(_this, CountdownTimer);
_classCallCheck(this, CountdownTimer);
_this = _possibleConstructorReturn(_this, _getPrototypeOf(CountdownTimer).call(_this, props));
_this = _possibleConstructorReturn(this, _getPrototypeOf(CountdownTimer).call(this, props));
_this.state = {
timeRemaining: this.props.timeLeft,
interval:1000,
prevTime: null
};

@@ -68,4 +67,4 @@ return _this;

is_mounted = true;
_this.startTimer();
_this.interval = setInterval(_this.startTimer.bind(_this), 1000);
this.startTimer();
this.interval = setInterval(this.startTimer.bind(this), 1000);
}

@@ -75,3 +74,3 @@ }, {

value: function componentWillUnmount() {
clearInterval(_this.interval);
clearInterval(this.interval);
}

@@ -82,4 +81,5 @@ }, {

const currentTime = Date.now();
const differenceInTime = _this.state.prevTime ? (currentTime - _this.state.prevTime) : 0;
const interval = _this.props.interval;
console.log(this.state);
const differenceInTime = this.state.prevTime ? (currentTime - this.state.prevTime) : 0;
const interval = this.props.interval;
const timeRemainingInInterval = interval - (differenceInTime % interval)

@@ -90,7 +90,7 @@ let timeout = timeRemainingInInterval;

}
const timeRemaining = Math.max(_this.state.timeRemaining - differenceInTime, 0);
const countdownComplete = (_this.state.prevTime && timeRemaining <= 0);
const timeRemaining = Math.max(this.state.timeRemaining - differenceInTime, 0);
const countdownComplete = (this.state.prevTime && timeRemaining <= 0);
if (is_mounted) {
_this.setState({
timeoutId: countdownComplete? null : setInterval(_this.startTimer, timeout),
this.setState({
timeoutId: countdownComplete? null : setInterval(this.startTimer, timeout),
prevTime: currentTime,

@@ -100,8 +100,8 @@ timeRemaining: timeRemaining

}
if (countdownComplete && _this.props.completeCallback) {
_this.props.completeCallback();
_this.componentWillUnmount();
if (countdownComplete && this.props.completeCallback) {
this.props.completeCallback();
this.componentWillUnmount();
}
if (_this.props.tickCallback) {
_this.props.tickCallback(timeRemaining);
if (this.props.tickCallback) {
this.props.tickCallback(timeRemaining);
}

@@ -130,3 +130,3 @@ },

}, _react.default.createElement("div", {
}, " ", _this.getFormattedTime(_this.state.timeRemaining)));
}, " ", this.getFormattedTime(this.state.timeRemaining)));
}

@@ -133,0 +133,0 @@ }]);

{
"name": "timer-countdown",
"version": "0.0.7",
"version": "0.0.8",
"description": "A well designed ReactJs component for timer-counter",

@@ -5,0 +5,0 @@ "main": "lib/CountdownTimer.js",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc