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

async3

v0.0.2

Published

Procedural asynchronous flow control for JavaScript in Node.JS and browsers.

Downloads

6

Readme

async3.js

Procedural asynchronous flow control for JavaScript in Node.JS and browsers.

For people who find continuation passing style (CPS) more reasonable than Promises, Futures, generators, etc.

Inspired by async2, mini-async.

Motivation

Javascript, like many languages that support passing callbacks to asynchronous APIs, provides flow control keywords (i.e, if, while, for) that are nearly useless once you need to await the future result.

At some point you realize you need to take a procedural approach and reimplement these keywords as functions.

In doing so, if you are familiar with assembly or machine code, you may realize that all flow control operations can actually be reduced to conditional JMP opcodes. Trendy variations like unless, until, do...while, etc. are unecessary syntactic sugar.

Taking the minimalist approach, you realize you can get a large degree of control with just a few functions that are a few lines of code each. No need for object instantiations, or multiple function calls in a builder pattern.

Include

ES6 Node.JS:

const {ifAsync} = require('async3');

Flow Control Functions

Async3.ifAsync()

For when you have two functions: one that is asynchronous but is only executed sometimes, and one that is called afterward. Without this, you'd have to declare or reference the second function twice.

Syntax
void ifAsync(test, true_cb[, ...args], done_cb);
Parameters
  • test
    Truthy value determines whether to invoke true_cb.

  • true_cb
    The function invoked if the test function above returns truthy. Accepts no targ Expected to be asynchronous. Accepts arguments provided in ...args parameter described below. Void return value.

  • ...args
    Optional. One or more arguments of any type, to be passed into true_cb function.

  • done_cb
    Function invoked after true_cb completes. Invoked regardless of whether test returned truthy.

Example
ifAsync(tmpAbsPath != absPath,
  exec, 'mv "'+ tmpAbsPath +'" "'+ absPath +'"', () =>
{
  console.log('placed locally for later static upload to cdn as '+ relPath);
});