New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

notatimer

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

notatimer

Stopwatch framework

latest
Source
npmnpm
Version
0.3.0
Version published
Maintainers
1
Created
Source

notatimer

notatimer is "not a timer." It is, in fact, a stopwatch, though it doesn't stop some people (see: speedrunners) from calling it a timer.

Install

npm i notatimer

Requiring/Importing

// CommonJS
const Stopwatch = require('notatimer');

// ESM
import Stopwatch from 'notawatch';

It is a default export, so it can be named whatever you want.

Creating an Instance

const stopwatch = new Stopwatch()

Optionally, an object can be passed into the constructor, with three possible properties.

const stopwatch = new Stopwatch({
    initial: 0, // must be a number
    delay: 0, // must be a nonnegative number
    callback: null // must be a function with one parameter -- details below
})

The callback function is passed an object containing a time property and times property.

These three properties can be updated after construction using stopwatch.set(object).

Usage

Properties

stopwatch.time

Current time in milliseconds (accurate to 5 microseconds).

stopwatch.times

Current time as an array in the format [hours, minutes, seconds, milliseconds].

stopwatch.started

If the stopwatch has started (true/false).

stopwatch.running

If the stopwatch is currently running (true/false).

stopwatch.finished

If the stopwatch has finished (true/false).

stopwatch.initial

The initial time for the stopwatch (use the constructor or stopwatch.set() to set).

stopwatch.delay

The initial delay for the stopwatch (use the constructor or stopwatch.set() to set).

stopwatch.laps

Array of objects, each with a time property and times property.

stopwatch.callback

Function that is called every step or when setting a property. Use this function to update where the time is displayed.

Methods

stopwatch.start()

Start the timer. Returns void.

stopwatch.pause()

Pause the timer. Returns void.

stopwatch.stop()

Stops the timer. Returns an object with a time property and times property.

stopwatch.reset()

Stops and resets the timer to the initial value. Returns void.

stopwatch.lap()

Adds an object with a time property and times property to thestopwatch.laps array. Returns the aforementioned object.

stopwatch.set(object)

Sets the initial property, delay property, and/or callback function. Returns void.

Keywords

stopwatch

FAQs

Package last updated on 20 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts