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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ng-workerbee

v0.1.1

Published

Angular library Web Workers

Readme

Ng-Workerbee

This project was generated with Angular CLI version 10.0.8.

Why ng-workerbee?

Angular 8 introduced native support for Web Workers, however this support does not extend to Angular libraries. Ng-Workerbee makes use of the WorkerHelper class (written by klausj https://github.com/klausj and sourced from https://github.com/angular/angular-cli/issues/15059#issuecomment-584593180) to allow a developer to easily use Web Workers in a compiled Angular library. While developed specifically to support Web Workers in Angular libraries, ng-workerbee can be used in any Angular project.

Usage

Install

npm i ng-workerbee -or- clone the github repo and build the ng-workerbee app.

Imports

import {
  InitWorker,
  PostToWorker,
  BuildMessage,
} from 'ng-workerbee';

Initialize your worker in a component constructor:

  // InitWorker takes 2 parameters like:
  // InitWorker(processResponse: Function, that?: any)
  // 
  // the first is a function which should take 2 parameters like:
  // someFunction(response: MessageResponse, that: myComponent)
  // 
  // the second should be an object or an instance of
  // your component if you wish your worker to "return" a value.
  // 
  // It is suggested to use a Subject(BehaviorSubject or ReplaySubject) here.
  data: MessageEvent;
  dataSubject = new Subject<MessageEvent>();
  testWorker: Worker;
  workerTest = function (data: MessageEvent, that: myComponent) {
    that.dataSubject.next(data)
    console.log(`initWorker got message: ${data.data}`);
  };
  constructor() {
    this.dataSubject.subscribe({
      next: (d) => this.data = d
    })
    this.testWorker = InitWorker(this.workerTest, this);
  }

Use BuildMessage to construct the second parameter for PostToWorker like:

// BuildMessage takes 3 parameterslike:
// BuildMessage( wFun: Function, params: any, depFuns: Function[] )
// 
// the first is the function your worker should execute, the 
// workerFunction, which MUST reuturn a Promise.
// this function should take one parameter, even should you decide
// that it is undefined.
// 
// the second is the parameter to be passed to the workerFunction
// 
// the third is an optional array of functions that the workerFunction
// is dependent on,  these dependency functions MUST be declared as
// exported functions like:
// export function myFunction(){ doStuff... }
// rather than as let myFun = function(){ doStuff... }
// in order to maintain their function names within the scope of the worker


  workerFunction(item): Promise<any> {
    return new Promise((resolve) => {
      if (valCompare(item)) {
        resolve('resolving with: ' + item.logVal);
      }
    });
  }
  valCompare(item): boolean {
  if (item.logVal === 'workerbee works!') {
    return true;
  } else {
    return false;
  }
}
params = { logVal: 'workerbee works!' }
testMessage = BuildMessage(workerFunction, params, [valCompare])

Use PostToWorker to invoke:

// PostToWorker takes 2 parameters like:
// PostToWorker(worker: Worker, message: workerMessageFormat)
// 
// the first is the worker to which the message should be posted
// 
// the second is a message of type {workerMessageFormat}
// (returned by BuildMessage)
// When the worker completes, the function you provided to InitWorker will be
// invoked with the resolution of your workerFunction and the Component instance 
// you passed to InitWorker(if any).
// DONE.
    PostToWorker(
      this.testWorker,
      this.testMessage
    );

Demo

To run the sample app, clone the github repo and run npm run build ng-workerbee && npm start

WorkerHelper class sourced from https://github.com/angular/angular-cli/issues/15059#issuecomment-584593180