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

@typescript-package/promise

v1.1.0

Published

A lightweight TypeScript library for promises.

Downloads

224

Readme

@typescript-package/promise

npm version GitHub issues GitHub license

A lightweight TypeScript library for promises.

Table of contents

Installation

npm install @typescript-package/promise --save-peer

Api

import {
  Deferred,
  LazyDeferred,
  LazyPromise
} from '@typescript-package/data';

Concrete

Deferred

import { Deferred } from '@typescript-package/promise';

// Creates a new Deferred instance and resolves it with the value 42, then logs the resolved value to the console
const deferred = new Deferred<number>();
// Resolves the deferred with a value of 42 and logs it to the console
deferred.resolve(42);
// Attaches a then handler to the deferred that logs the resolved value to the console when the promise is fulfilled
deferred.then(value => {
  console.log('Resolved value:', value);
});
// Creates a new Deferred instance and rejects it with an error, then logs the error to the console
deferred.catch(error => {
  console.error('Error:', error);
});

Source

LazyDeferred

import { LazyDeferred } from '@typescript-package/promise';

// Creates a new LazyDeferred instance with a factory function that returns the value 42
const lazyDeferred = new LazyDeferred(() => 127);

// Attaches a then handler to the lazy deferred that logs the resolved value to the console when the promise is fulfilled, and a catch handler that logs any errors to the console
await lazyDeferred.then(value => {
  console.log('Resolved with:', value);
}).catch(error => {
  console.error('Error:', error);
});

console.log(lazyDeferred.settled); // true
console.log(lazyDeferred.value); // 127

// Attaches a finally handler to the lazy deferred that logs a message to the console when the promise is settled (either resolved or rejected)
lazyDeferred.finally(() => {
  console.log('Promise settled');
});

lazyDeferred.reset(); // Resets the lazy deferred to its initial state, allowing it to be executed again with the same factory function

lazyDeferred.resolve(134); // Manually resolves the lazy deferred with the value 134, overriding the factory function
lazyDeferred.reject(new Error('Test error')); // Manually rejects the lazy deferred with an error, overriding the factory function

console.log(`lazyDeferred.settled`, lazyDeferred.settled); // true
console.log(`lazyDeferred.value`, lazyDeferred.value); // 134

Source

LazyPromise

import { LazyPromise } from '@typescript-package/promise';

const lazyPromise = new LazyPromise(() => 42);

console.log(`lazyPromise.settled`, lazyPromise.settled); // false
console.log(`lazyPromise.value`, lazyPromise.value); // undefined

// Attaches a callback that is invoked when the lazy promise is resolved.
await lazyPromise.then(value => {
  console.log('Resolved value:', value); // Resolved value: 42
}).catch(error => {
  console.error('Error:', error);
});

// Attaches a callback that is invoked when the lazy promise is settled (either resolved or rejected).
lazyPromise.finally(() => {
  console.log('Promise settled');
});

console.log(`lazyPromise.settled`, lazyPromise.settled); // true
console.log(`lazyPromise.value`, lazyPromise.value); // undefined

// Resets the lazy promise to its initial state, allowing it to be executed again with the same factory function.
// lazyPromise.reset();

Source

Contributing

Your contributions are valued! If you'd like to contribute, please feel free to submit a pull request. Help is always appreciated.

Support

If you find this package useful and would like to support its and general development, you can contribute through one of the following payment methods. Your support helps maintain the packages and continue adding new.

Support via:

or via Trust Wallet

Thanks for your support!

Code of Conduct

By participating in this project, you agree to follow Code of Conduct.

GIT

Commit

Versioning

Semantic Versioning 2.0.0

Given a version number MAJOR.MINOR.PATCH, increment the:

  • MAJOR version when you make incompatible API changes,
  • MINOR version when you add functionality in a backwards-compatible manner, and
  • PATCH version when you make backwards-compatible bug fixes.

Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.

FAQ How should I deal with revisions in the 0.y.z initial development phase?

The simplest thing to do is start your initial development release at 0.1.0 and then increment the minor version for each subsequent release.

How do I know when to release 1.0.0?

If your software is being used in production, it should probably already be 1.0.0. If you have a stable API on which users have come to depend, you should be 1.0.0. If you’re worrying a lot about backwards compatibility, you should probably already be 1.0.0.

License

MIT © typescript-package (license)

Packages