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

@xylabs/promise

v5.0.80

Published

Base functionality used throughout XY Labs TypeScript/JavaScript libraries

Readme

@xylabs/promise

logo

main-build npm-badge npm-downloads-badge jsdelivr-badge npm-license-badge codacy-badge codeclimate-badge snyk-badge socket-badge

Base functionality used throughout XY Labs TypeScript/JavaScript libraries

Reference

@xylabs/promise


Classes

Interfaces

Type Aliases

Functions

classes

PromiseEx

@xylabs/promise


Extends

  • Promise<T>

Type Parameters

T

T

V

V = void

Constructors

Constructor

new PromiseEx<T, V>(func, value?): PromiseEx<T, V>;

Parameters

func

PromiseExFunc<T>

value?

V

Returns

PromiseEx<T, V>

Overrides

Promise<T>.constructor

Properties

cancelled?

optional cancelled: boolean;

Methods

then()

then<TResult1, TResult2>(
   onfulfilled?, 
   onrejected?, 
onvalue?): Promise<TResult1 | TResult2>;

Attaches callbacks for the resolution and/or rejection of the Promise.

Type Parameters

TResult1

TResult1 = T

TResult2

TResult2 = never

Parameters

onfulfilled?

The callback to execute when the Promise is resolved.

null | (value) => TResult1 | PromiseLike<TResult1>

onrejected?

The callback to execute when the Promise is rejected.

null | (reason) => TResult2 | PromiseLike<TResult2>

onvalue?

(value?) => boolean

Returns

Promise<TResult1 | TResult2>

A Promise for the completion of which ever callback is executed.

Overrides

Promise.then

value()

value(onvalue?): PromiseEx<T, V>;

Parameters

onvalue?

(value?) => boolean

Returns

PromiseEx<T, V>

functions

fulfilled

@xylabs/promise


function fulfilled<T>(val): val is PromiseFulfilledResult<T>;

For use with Promise.allSettled to filter only successful results

Type Parameters

T

T

Parameters

val

PromiseSettledResult<T>

Returns

val is PromiseFulfilledResult<T>

fulfilledValues

@xylabs/promise


function fulfilledValues<T>(previousValue, currentValue): T[];

For use with Promise.allSettled to reduce to only successful result values

Type Parameters

T

T

Parameters

previousValue

T[]

currentValue

PromiseSettledResult<T>

Returns

T[]

Examples

const resolved = Promise.resolve('resolved')
const rejected = Promise.reject('rejected')
const settled = await Promise.allSettled([resolved, rejected])
const results = settled.reduce(fulfilledValues, [] as string[])
// results === [ 'resolved' ]
const resolved = Promise.resolve('resolved')
const rejected = Promise.reject('rejected')
const settled = await Promise.allSettled([resolved, rejected])
const results = settled.reduce<string[]>(fulfilledValues, [])
// results === [ 'resolved' ]

isPromise

@xylabs/promise


function isPromise(value): value is Promise<unknown>;

Parameters

value

unknown

Returns

value is Promise<unknown>

rejected

@xylabs/promise


function rejected<T>(val): val is PromiseRejectedResult;

For use with Promise.allSettled to filter only rejected results

Type Parameters

T

T

Parameters

val

PromiseSettledResult<T>

Returns

val is PromiseRejectedResult

toPromise

@xylabs/promise


function toPromise<T>(value): Promise<T>;

Type Parameters

T

T

Parameters

value

Promisable<T>

Returns

Promise<T>

interfaces

PromiseType

@xylabs/promise


Properties

then()

then: () => unknown;

Returns

unknown

type-aliases

AnyNonPromise

@xylabs/promise


type AnyNonPromise = Exclude<TypedValue, PromiseType>;

AsyncMutex

@xylabs/promise


type AsyncMutex<T> = Promise<T>;

Type Parameters

T

T

Description

Used to document promises that are being used as Mutexes

NullablePromisable

@xylabs/promise


type NullablePromisable<T, V> = Promisable<T | null, V>;

Type Parameters

T

T

V

V = never

NullablePromisableArray

@xylabs/promise


type NullablePromisableArray<T, V> = PromisableArray<T | null, V>;

Type Parameters

T

T

V

V = never

OptionalPromisable

@xylabs/promise


type OptionalPromisable<T, V> = Promisable<T | undefined, V>;

Type Parameters

T

T

V

V = never

OptionalPromisableArray

@xylabs/promise


type OptionalPromisableArray<T, V> = PromisableArray<T | undefined, V>;

Type Parameters

T

T

V

V = never

Promisable

@xylabs/promise


type Promisable<T, V> = PromiseEx<T, V> | Promise<T> | T;

Type Parameters

T

T

V

V = never

PromisableArray

@xylabs/promise


type PromisableArray<T, V> = Promisable<T[], V>;

Type Parameters

T

T

V

V = never

PromiseExFunc

@xylabs/promise


type PromiseExFunc<T> = (resolve?, reject?) => void;

Type Parameters

T

T

Parameters

resolve?

PromiseExSubFunc<T, void>

reject?

PromiseExSubFunc<T, void>

Returns

void

PromiseExSubFunc

@xylabs/promise


type PromiseExSubFunc<T, TResult> = (value) => TResult;

Type Parameters

T

T

TResult

TResult = T

Parameters

value

T

Returns

TResult

PromiseExValueFunc

@xylabs/promise


type PromiseExValueFunc<V> = (value?) => boolean;

Type Parameters

V

V

Parameters

value?

V

Returns

boolean

Part of sdk-js

Maintainers

License

See the LICENSE file for license details

Credits

Made with 🔥 and ❄️ by XYLabs