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 🙏

© 2025 – Pkg Stats / Ryan Hefner

js-synchronized

v0.0.6

Published

``` npm install --save js-synchronized ```

Readme

js-synchronized

npm install --save js-synchronized

Sometimes the Promise act like multiple thread. For several lines of code in a function, when one call already waiting on a Promise been fulfilled, another call may come in, just like "concurrent" in mutiple thread. Which make the lies of code a "critical section".

There is critical section, there is synchronization. This lib is trying to solve these problems.

Full Documentation

"concurrent calls" in the following context actullay means another call on a method started without waiting for the previous call returned Promise fulfilled

synchronized

Make target instance method execute sequentially on "concurrent calls". It actually make every call on async method wait until the previously returned Promise fulfilled.

Example

class SomeClass {

  @synchronized()
  public async f1(wait: number) {
    await new Promise((resolve: any) => {
      setTimeout(resolve, wait);
    });
    console.log('f1-' + wait);
    return wait;
  }

}

const obj = new SomeClass();
obj.f1(3000);
obj.f1(2000);
obj.f1(1000);

The f1() will execute sequentially, so event the obj1.f1(3000) fulfilled take longer than obj1.f1(1000), the 1000 have to wait 3000 finish first.

takeLatest

Make all "concurrent calls" on target intance method return the value of the most latest call, all results of previous calls are abandoned.

takeLeading

Make all "concurrent calls" on target intance method return the value of the most leading call, all results of afterwards calls are abandoned.