Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-compound-timer

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-compound-timer - npm Package Compare versions

Comparing version 1.0.13 to 1.1.0

build/components/TimerOnHooks/TimerOnHooks.d.ts

9

build/components/Timer/Timer.d.ts
import React from 'react';
import { TimePartsType } from '../../lib/helpers/getTimeParts';
import { TimerStateType } from '../../lib/models/TimerState';
import { TimerStateValues, TimeParts } from 'src/types';
declare type FormatValueType = (value: number) => string;
declare type TimerContextType = TimePartsType & {
declare type TimerContextType = TimeParts & {
formatValue: FormatValueType;

@@ -40,4 +39,4 @@ };

}
interface TimerState extends TimePartsType {
timerState: TimerStateType;
interface TimerState extends TimeParts {
timerState: TimerStateValues;
}

@@ -44,0 +43,0 @@ declare class Timer extends React.PureComponent<TimerProps, TimerState> {

@@ -26,3 +26,3 @@ var __extends = (this && this.__extends) || (function () {

import React from 'react';
import TimerModel from '../../lib/models/TimerModel';
import { TimerModel } from '../../lib/models/TimerModel';
var TimerContext = React.createContext({

@@ -29,0 +29,0 @@ ms: 0,

@@ -1,9 +0,2 @@

export declare type Unit = 'ms' | 's' | 'm' | 'h' | 'd';
export interface TimePartsType {
ms: number;
s: number;
m: number;
h: number;
d: number;
}
export default function getTimeParts(time: number, lastUnit: Unit): TimePartsType;
import { Unit, TimeParts } from "src/types";
export default function getTimeParts(time: number, lastUnit: Unit): TimeParts;

@@ -1,8 +0,3 @@

import { Unit, TimePartsType } from '../helpers/getTimeParts';
export interface Checkpoint {
time: number;
callback: () => any;
}
export declare type Direction = 'forward' | 'backward';
export default class Timer {
import { TimeParts, Checkpoint, Direction, TimerValue, Unit } from 'src/types';
export declare class TimerModel {
private initialTime;

@@ -23,8 +18,8 @@ private time;

checkpoints: Checkpoint[];
onChange: () => any;
onChange: (timerValue?: TimerValue) => void;
});
readonly state: import("./TimerState").TimerStateType;
readonly timeParts: TimePartsType;
getTimeParts(time: any): TimePartsType;
setTime(time: any): void;
readonly state: import("../../types").TimerStateValues;
readonly timeParts: TimeParts;
getTimeParts(time: any): TimeParts;
setTime(time: number): void;
getTime(): number;

@@ -31,0 +26,0 @@ setDirection(direction: any): void;

import getTimeParts from '../helpers/getTimeParts';
import TimerState from './TimerState';
var Timer = /** @class */ (function () {
function Timer(_a) {
var _b = _a.initialTime, initialTime = _b === void 0 ? 0 : _b, _c = _a.direction, direction = _c === void 0 ? 'forward' : _c, _d = _a.timeToUpdate, timeToUpdate = _d === void 0 ? 1000 : _d, _e = _a.lastUnit, lastUnit = _e === void 0 ? 'd' : _e, _f = _a.checkpoints, checkpoints = _f === void 0 ? [] : _f, _g = _a.onChange, onChange = _g === void 0 ? function () { } : _g;
var TimerModel = /** @class */ (function () {
function TimerModel(_a) {
var initialTime = _a.initialTime, direction = _a.direction, timeToUpdate = _a.timeToUpdate, lastUnit = _a.lastUnit, checkpoints = _a.checkpoints, onChange = _a.onChange;
this.initialTime = initialTime;

@@ -16,3 +16,3 @@ this.time = initialTime;

}
Object.defineProperty(Timer.prototype, "state", {
Object.defineProperty(TimerModel.prototype, "state", {
get: function () {

@@ -24,3 +24,3 @@ return this.innerState.getState();

});
Object.defineProperty(Timer.prototype, "timeParts", {
Object.defineProperty(TimerModel.prototype, "timeParts", {
get: function () {

@@ -32,18 +32,18 @@ return this.getTimeParts(this.computeTime());

});
Timer.prototype.getTimeParts = function (time) {
TimerModel.prototype.getTimeParts = function (time) {
return getTimeParts(time, this.lastUnit);
};
Timer.prototype.setTime = function (time) {
TimerModel.prototype.setTime = function (time) {
this.time = time;
};
Timer.prototype.getTime = function () {
TimerModel.prototype.getTime = function () {
return this.time;
};
Timer.prototype.setDirection = function (direction) {
TimerModel.prototype.setDirection = function (direction) {
this.direction = direction;
};
Timer.prototype.setCheckpoints = function (checkpoints) {
TimerModel.prototype.setCheckpoints = function (checkpoints) {
this.checkpoints = checkpoints;
};
Timer.prototype.start = function () {
TimerModel.prototype.start = function () {
if (this.innerState.setPlaying()) {

@@ -53,3 +53,3 @@ this.setTimerInterval(true);

};
Timer.prototype.resume = function () {
TimerModel.prototype.resume = function () {
if (!this.innerState.isStopped() && this.innerState.setPlaying()) {

@@ -59,3 +59,3 @@ this.setTimerInterval();

};
Timer.prototype.pause = function () {
TimerModel.prototype.pause = function () {
if (this.innerState.setPaused()) {

@@ -65,3 +65,3 @@ clearInterval(this.timerId);

};
Timer.prototype.stop = function () {
TimerModel.prototype.stop = function () {
if (this.innerState.setStopped()) {

@@ -71,7 +71,7 @@ clearInterval(this.timerId);

};
Timer.prototype.reset = function () {
TimerModel.prototype.reset = function () {
this.time = this.initialTime;
this.onChange(this.getTimeParts(this.time));
};
Timer.prototype.setTimerInterval = function (callImmediately) {
TimerModel.prototype.setTimerInterval = function (callImmediately) {
var _this = this;

@@ -98,3 +98,3 @@ if (callImmediately === void 0) { callImmediately = false; }

};
Timer.prototype.computeTime = function () {
TimerModel.prototype.computeTime = function () {
if (this.innerState.isPlaying()) {

@@ -119,5 +119,5 @@ switch (this.direction) {

};
return Timer;
return TimerModel;
}());
export default Timer;
export { TimerModel };
//# sourceMappingURL=TimerModel.js.map

@@ -0,1 +1,2 @@

import { TimerStateValues } from "src/types";
export declare const INITED = "INITED";

@@ -5,3 +6,2 @@ export declare const PLAYING = "PLAYING";

export declare const STOPPED = "STOPPED";
export declare type TimerStateType = 'INITED' | 'PLAYING' | 'PAUSED' | 'STOPPED';
export default class TimerState {

@@ -11,5 +11,5 @@ private onChange;

constructor(onChangeStatus?: (obj: {
timerState: TimerStateType;
state: TimerStateValues;
}) => void);
getState(): TimerStateType;
getState(): TimerStateValues;
setInited(): boolean;

@@ -16,0 +16,0 @@ isInited(): boolean;

@@ -10,3 +10,3 @@ export var INITED = 'INITED';

this.state = INITED;
this.onChange = function () { return onChangeStatus({ timerState: _this.state }); };
this.onChange = function () { return onChangeStatus({ state: _this.state }); };
this.state = INITED;

@@ -13,0 +13,0 @@ }

{
"name": "react-compound-timer",
"version": "1.0.13",
"version": "1.1.0",
"description": "Timer compound react component",
"main": "build/components/Timer/Timer",
"types": "build/components/Timer/Timer.d.ts",
"main": "build",
"types": "build",
"keywords": [

@@ -8,0 +8,0 @@ "react",

@@ -13,3 +13,6 @@ {

"declaration": true,
"outDir": "./build"
"outDir": "./build",
"paths": {
"src/*": ["src/*"]
}
},

@@ -16,0 +19,0 @@ "exclude": ["node_modules", "build", "src/**/*.test.tsx", "src/**/*.test.ts"],

@@ -12,2 +12,5 @@ const path = require('path');

resolve: {
alias: {
src: path.resolve(__dirname, 'src'),
},
extensions: ['.ts', '.tsx'],

@@ -14,0 +17,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc