Socket
Socket
Sign inDemoInstall

@matrixai/timer

Package Overview
Dependencies
3
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.1.0

3

dist/Timer.d.ts

@@ -115,3 +115,3 @@ import type { PromiseCancellableController } from '@matrixai/async-cancellable';

* Refreshes the timer to the original delay and updates the scheduled time.
* If the timer has already ended this does nothing.
* @throws {ErrorTimerEnded} If the timer is `settling` or `settled`
*/

@@ -121,2 +121,3 @@ refresh(): void;

* Resets the timer with a new delay and updates the scheduled time and delay.
* @throws {ErrorTimerEnded} If the timer is `settling` or `settled`
*/

@@ -123,0 +124,0 @@ reset(delay: number): void;

@@ -187,15 +187,15 @@ import { performance } from 'node:perf_hooks';

* Refreshes the timer to the original delay and updates the scheduled time.
* If the timer has already ended this does nothing.
* @throws {ErrorTimerEnded} If the timer is `settling` or `settled`
*/
refresh() {
if (this.timeoutRef == null)
if (this._status != null)
throw new ErrorTimerEnded();
this.timeoutRef.refresh();
this._scheduled = new Date(performance.timeOrigin + performance.now() + this._delay);
return this.reset(this._delay);
}
/**
* Resets the timer with a new delay and updates the scheduled time and delay.
* @throws {ErrorTimerEnded} If the timer is `settling` or `settled`
*/
reset(delay) {
if (this.timeoutRef == null)
if (this._status != null)
throw new ErrorTimerEnded();

@@ -215,3 +215,3 @@ // This needs to re-create the timeout with the constructor logic.

this.timeoutRef = setInterval(() => { }, 2 ** 31 - 1);
this._scheduled = undefined;
delete this._scheduled;
}

@@ -235,6 +235,7 @@ }

}
delete this.handler;
this._status = 'settled';
}
async reject(reason) {
if ((this.lazy && (this._status == null || this._status === 'settling')) ||
if ((this.lazy && this._status === 'settling') ||
this._status === 'settled') {

@@ -247,2 +248,3 @@ return;

this.rejectP(reason);
delete this.handler;
this._status = 'settled';

@@ -249,0 +251,0 @@ }

{
"name": "@matrixai/timer",
"version": "2.0.0",
"version": "2.1.0",
"author": "Roger Qiu",

@@ -5,0 +5,0 @@ "description": "Stopwatch timer object",

@@ -16,2 +16,11 @@ # js-timer

## Usage
```ts
import { Timer } from '@matrixai/timer';
const t1 = new Timer(() => 2, 10);
const result = await t1;
```
## Development

@@ -18,0 +27,0 @@

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