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

exert

v0.0.3

Published

A small library to create watchable/observable classes with decorators

Downloads

6

Readme

Exert

Exert is a very simple library that allows to create watchables. Watchables are subscribable classes in which you can control publish timings.

It works by taking advantage of ES next decorators.

Installation

npm install exert

You will also want to setup your project to support class and object decorators. See: https://babeljs.io/docs/plugins/transform-decorators/

How it works

Create a watchable class.

import { watchable, change, changeAsync } from 'exert';

@watchable()
class MyWatchable {
  constructor() {
    this.firstName = 'Scott';
  }

  // @change decorator will automatically notify all subscriptions after
  // changes are made.  Works with synchronous methods.
  @change setName(firstName) {
    this.firstName = firstName;
  }

  // @changeAync will pass the "done" function as the last argument.
  // Use with async methods such as calling a backend REST call.
  @changeAsync setNameAsync(firstName, done) {
     window.setTimeout(()=> {
       this.firstName = firstName;
       done();
     }, 1000);
  }
}

In the above, we use @change and @changeAsync decorators to publish out to subscribers. Generally any changes to public properties should be changed via a method decorated with @change or @changeAsync so that subscribers are correctly called.

Now that we have setup our class, we are ready to instantiate it and start subscribing/watching the class.

let myWatchable = new MyWatchable();

let onUpdate = (current, prev)=> {
  console.log('name was:' + prev.firstName);
  console.log('name is now:' + current.firstName);
  // Do whatever you want.
  // Typically, you may want to update/render the view.
}

// Subscribe to the stream updates. This will fire the next time a change is
// made.
myWatchable.watch(onUpdate);

// Subscribe and immidiately calls onUpdate.
myWatchable.watchNow(onUpdate);

// Make a change.
myWatchable.setName('John'); // You should see onUpdate called.

// Unsubscribe.
myWatchable.unwatch(onUpdate);

// Subscribe Once
myWatchable.watchOnce(onUpdate);

// Make async change
myWatchable.setNameAsync('Michael');  // You should see onUpdate called again.

Contribute

Installation

npm install

Scripts

  • yarn build or npm run build - General lib files.
  • yarn dev or npm run dev - Produce dev version of lib and watch files.
  • yarn test or npm run test - Run tests
  • yarn test:watch or npm run test:watch - Run tests and watch.

To publish: npm publish