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

@streamhive/quick-pack

v1.0.1

Published

A Webpack configuration optimizer

Readme

true-promise

A cancelable & typed Promise for TypeScript, Node.js & the browser.

Installation

npm install @streamhive/true-promise --save  
yarn add @streamhive/true-promise  

Features

Extended Promises

Use cancel, resolve, reject & finally on your Promise, otherwise it's just like a regular Promise.

100% Compatible

Includes babel polyfill to run your Promises without global scope pollution, it's ready-to-use.

Built-in Types

Types for TypeScript and your IDE so you can write stuff like this & avoid development errors.

new TruePromise<string, number>((resolve, reject) => {
     resolve(42000); // TS Error
     reject('Oops'); // TS Error
});

How to use

ES7+ | TypeScript

const promise0 = new TruePromise<string, number>((resolve) => {  
     setTimeout(() => resolve('I <3 Promises'), 500);  
});  

const promise1 = promise0.then(() => "Won't execute");  
  
promise0.cancel('I <3 Cancelling');  
  
console.log(await promise0);  
console.log(await promise1);

Remember to remove the types when using vanilla JavaScript.

ES5+ | Browser

<script type="text/javascript" src="true-promise.web.js"></script>  
<script type="text/javascript">  
  new TruePromise.default(function () {  
          alert('I <3 Promises')  
  });  
</script>

Documentation

Do you want to know more about .resolved(), .rejected(), ... ?

Visit Quick API Manual

Examples

Let's take a few examples through a practical. If you are not using TypeScript just remove the types.

Create a basic Promise

// Create a Promise that resolves a string and errors a number  
const promise0 = new TruePromise<string, number>((resolve) => {  
     setTimeout(() => resolve('promise0'), 500);  
});  
  
// Let's chain the Promise with then  
const promise1 = promise0.then((v) => {  
     return 'promise1';  
});  
  
// Which returns a Promise  
console.log(await promise0);  
console.log(await promise1);

promise0
promise1

Cancel your first Promise manually

// Create a Promise that resolves a string and errors a number
const promise0 = new TruePromise<string, number>((resolve) => {
     setTimeout(() => resolve('promise0'), 500);
});

// Let's chain the Promise with then
const promise1 = promise0.then((v) => {
     return 'promise1';
});

// Let's chain the Promise with then 
const promise2 = promise1.then((v) => {
     return 'promise2';
});

promise0.cancel('canceled');

// Which returns a Promise 
console.log(await promise0);
console.log(await promise1);
console.log(await promise2);

canceled
undefined
undefined

Why did it display undefined ? We canceled the parent Promise so promise1 could not yield a result (and any chained/nested Promise).

Only a pending promise can be canceled. Use .status() to check it's current status.

Resolve or reject your Promise manually

// Create a Promise that resolves a string and errors a number  
const promise0 = new TruePromise<string, number>((resolve) => {
     setTimeout(() => resolve('promise0'), 500);
});

// Let's chain the Promise with then  
const promise1 = promise0.then((v) => {
     return 'promise1';
});

promise0.resolve('resolved');
promise1.reject('42');

// Which returns a Promise  
console.log(await promise0);
console.log(await promise1);

resolved
Error: Unhandled Rejection: 42

Only a pending promise can be rejected or resolved. Use .status() to check it's current status.

Todos

  • Write more serious tests.

License

AGPL 3.0