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

parallise

v0.2.1

Published

Promise executed parallely in worker and chainable/thenable in main context.

Downloads

13

Readme

parallise

Special Promise, which content is executed parallely in web-worker and chainable in main context.

It's still in development. I am basically polishing everything, enhancing stuff and writing tests.
Any constructive feedback would by very appreciated.
Use project's github page. Thanks.

Main purpose is to create Promises in web-workers, thenable in main context.

You should use it only in browser, since node does not provide Worker API. In this time, it has not been tested on node with fake Worker APIs.

npm install parallise

It uses some specific APIs:

Blob: https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob - I don't use it in workers so, don't worry about support.

window.URL.createObjectURL() : https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL#Browser_compatibility - Which has good basic support.

Tests will come soon.

Example of usage:

  import Parallise from 'parallise';
  // or
  var Parallise = require('parallise');

  Parallise(function (resolve, reject) {
    console.log("inside worker promise");
    resolve(23);
    }
  )
  .then(result => {console.log(result); return result * 2})
  .then(result => console.log(result));

  console.log("this will execute before then");

Even use arrow functions:

  import Parallise from 'parallise';
  // or
  var Parallise = require('parallise');

  Parallise((resolve, reject) => console.log("inside worker promise") || resolve(23))
  .then(result => {console.log(result); return result * 2})
  .then(result => console.log(result));

  console.log("this will execute before then");

Now you can also specify your own this object, inside worker thread. Use it like this:

  import Parallise from 'parallise';
  // or
  var Parallise = require('parallise');

  Parallise(function (resolve, reject) {
    console.log("inside worker promise");
    resolve(this.multiplier * 23);
    },
    {multiplier: 4}
  )
  .then(result => {console.log(result); return result * 2})
  .then(result => console.log(result));

  console.log("this will execute before then");

Executed function

Function expression which you are supplying into Parallise function can be either old fashioned function expression or new => operator. In this time it cannot make use of async functions, in future maybe parallel iterators will be introduced.

It's worker-less!

Main reason why you should choose this package is because it doesn't use native - separate file - Worker creation. So you are not forced to configure you webpack/browserify to split bundle and server worker.js file separately.

It depends on native Promises yet. I will add polyfill support lately. Actually just now, Promises are used only in main context/thread. Inside worker there is my own and very simply logic.