npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@y0urstruly/timer

v1.0.2

Published

reliable timer modules unlike default ones

Downloads

44

Readme

Timer (for JavaScript)

Custom and more accurate setInterval and setTimeout functionality that is not nerfed for things like when the browser tab is not in focus

Features

  • Roughly 99% accurate real time intervals in JavaScript
  • More precision than a whole millisecond; fractional values supported
  • Alternate version with only whole millisecond precision but with a smaller footprint on the JavaScript Event Loop

Installation

Install via:

npm install @y0urstruly/timer

Usage

JavaScript

  • Main Timer Library
const {timeout,interval,wait,clear} = require('@y0urstruly/timer');
  • Alternate Timer Library
const {timeout,interval,wait,clear} = require('@y0urstruly/timer/docile');

TypeScript

  • Main Timer Library
import {timeout,interval,wait,clear} = from '@y0urstruly/timer';
  • Alternate Timer Library
import {timeout,interval,wait,clear} = from '@y0urstruly/timer/docile';

Modules

  • interval(userFN:()=>void, ms:number): number: better setInterval, first argument is function, second argument is ms, returns ID
  • timeout(userFN:()=>void, ms:number): number: better setTimeout, first argument is function, second argument is ms, returns ID
  • wait(ms:number): Promise<void>: all you python sleep using kids, your functionality offered by a promise wrapped around timeout (tldr; await wait(ms))
  • clear(ID:number): boolean: removes any interval or timeout by ID. For example clear(timeout(someFN)) is a waste of code since someFN will never run

Disclaimers

  • It is more precise in nodejs (>300 events per ms ~~at least on a github codespace~~)
  • It is less precise in a browser (~10 events per ms ~~at least on a chrome tab~~)
  • The 2 points above were determined by comparing a 0ms interval to a 1ms interval and the ratio of their calls
  • Of course, sub ms timers might lose precision since functions take time to execute (tested on codespace for 0.2ms and got 98% precision instead) so it is recommended to have fractional timer values greater than 1
  • The smaller the fractional part, the less accurate (1.1 would be more accurate than 2.01)

Comparison to Native Modules

  • This section will always be dedicated to displaying the test results of the current commit https://i.sstatic.net/gwZgawnI.png