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

@virtualstate/promise

v1.4.0

Published

> Psst... There is a blog post at [fabiancook.dev](https://fabiancook.dev/2022/02/26/an-async-thing) with details on how > this project came to be, and the steps taken during implementation to define the included functionality.

Downloads

38

Readme

@virtualstate/promise

Psst... There is a blog post at fabiancook.dev with details on how this project came to be, and the steps taken during implementation to define the included functionality.

Support

Node.js supported Deno supported

Test Coverage

96.23%25 lines covered 96.23%25 statements covered 92.81%25 functions covered 93.06%25 branches covered

all

import { all } from "@virtualstate/promise";

// logs []
console.log(await all());
// logs [1, 2]
console.log(await all(Promise.resolve(1), Promise.resolve(2)));
// logs rejected
console.log(
    await all(Promise.resolve(1), Promise.reject(2))
        .catch(() => "rejected")
);

const wait = (timeout = 1, arg = undefined) => new Promise(resolve => setTimeout(resolve, timeout, arg));

for await (const state of all(
    wait(10, "first index, second resolve"),
    wait(1, "second index, first resolve")
)) {
    /*
    logs
    { state: [undefined, "second index, first resolve"] }
    { state: ["first index, second resolve", "second index, first resolve"] }
     */
    console.log({ state });
}

allSettled

import { allSettled } from "@virtualstate/promise";

// logs []
console.log(await allSettled());
// logs [
//   { value: 1, status: 'fulfilled' },
//   { value: 2, status: 'fulfilled' }
// ]
console.log(await allSettled(Promise.resolve(1), Promise.resolve(2))); 
// logs [
//   { value: 1, status: 'fulfilled' },
//   { reason: 2, status: 'rejected' }
// ]
console.log(await allSettled(Promise.resolve(1), Promise.reject(2)));

const wait = (timeout = 1, arg = undefined) => new Promise(resolve => setTimeout(resolve, timeout, arg));

for await (const state of allSettled(
    wait(10, "A"), 
    wait(1, "B"),
    wait(15).then(() => Promise.reject("C"))
)) {
    /*
    logs
    {
      state: [ undefined, { value: 'B', status: 'fulfilled' }, undefined ]
    }
    {
      state: [
        { value: 'A', status: 'fulfilled' },
        { value: 'B', status: 'fulfilled' },
        undefined
      ]
    }
    {
      state: [
        { value: 'A', status: 'fulfilled' },
        { value: 'B', status: 'fulfilled' },
        { reason: 'C', status: 'rejected' }
      ]
    }
     */
    console.log({ state });
}

Contributing

Please see Contributing

Code of Conduct

This project and everyone participating in it is governed by the Code of Conduct listed here. By participating, you are expected to uphold this code. Please report unacceptable behavior to [email protected].

Licence

This repository is licensed under the MIT license.