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

async-unsucked

v1.2.0

Published

Simplify the usage of async, await and Promise

Downloads

3

Readme

Async Unsucked

A simple, tiny, 0 dependency library to simplify the usage of asynchronous operations.

async function example() {
    const req = async(axios.get('http://localhost:3000/'))
    const [reply, data] = await Promise.all([
        req.data.reply,
        req.data
    ])
    console.log(reply, data) // "hello", {"reply": "hello"}
}


async function destructuring() {
    const req = async(axios.get('http://localhost:3000/'))
    const { reply } = req.data
    console.log(await reply) // "hello"
}


async function wrap() {
    const fetcher = async.wrap(axios.get)
    const { reply } = fetcher('http://localhost:3000/').data
    console.log(await reply) // "hello"
}



async function all() {
    const req = async(axios.get('http://localhost:3000/'))
    const obj = await async.all({
        reply: req.data.reply,
        data: req.data
    })
    console.log(obj) // { data :{'hello', { reply: 'hello'} } }
    const arr = await async.all([
        req.data.reply,
        req.data
    ])
    // same as Promise.all
    console.log(arr) // [ 'hello', { reply: 'hello'} ]
}



async function mix() {
    const req = async(axios.get('http://localhost:3000/'))
    const arr = await async.all([
        req.then(res => res.data.reply), // still works
        req.data
    ])
    console.log(arr) // [ 'hello', { reply: 'hello'} ]
}


async function map() {
    const req = async(axios.get('http://localhost:3000/'))
    const arr = [1, req.data.reply, 4]
    const res = async.map(arr, (c, i, err) => {
        if (err) console.log(err)
        else console.log(c, i)
        // 1 0
        // 4 2
        // hello 1
        return c
    })
    console.log(await res) // [ 1, 'hello', 4 ]
}

|| | |--|--| |async(p: Promise)| Make it possible to get sub-properties from Promise objects using Proxies. | |async.wrap(func: Function)|Wraps the return value of a function with async()| |async.all(promises: Promise[])| Same as Promise.all but supports objects aswell. | |async.allSettled(promises: Promise[])|Same as Promise.allSettled but supports objects aswell.| |async.race(promises: Promise[]) | Same as Promise.race but supports objects aswell. | |async.map(arr: Promise[], callback: Function) | Map async iterator.|

Pull requests are more then welcome.