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

@crikey/stores-base-queue

v0.0.13

Published

Internal peer package used to ensure signals emitted from stores are executed in a reliable predictable manner even as stores and subscriptions are changed.

Downloads

26

Readme

@crikey/stores-base-queue

Internal peer package used to ensure signals emitted from stores are executed in a reliable predictable manner even as stores and subscriptions are changed.

See @crikey/stores-base-queue for full documentation.

codecov

API

Queue functions

  • enqueue_store_signals - add actions onto the queue

Action running:

  • store_runner - Current (global) action runner
  • set_store_runner - Set current (global) action runner
  • get_store_runner - Get current (global) action runner

Default action runners:

  • store_runner_hide_errors - Swallow all error emitted by actions
  • store_runner_throw_errors - Do not handle errors emitted by actions
  • create_store_runner_log_errors - Create an action runner which logs errors emitted by actions

Installation

Note: It is important that this package be installed as a peer dependency to ensure the queue is shared between store implementations

# pnpm
$ pnpm add --save-peer @crikey/stores-base-queue

# npm
$ npm add --save-peer @crikey/stores-base-queue

# yarn
$ yarn add --peer @crikey/stores-base-queue

Usage

Enqueue the provided actions using a FIFO queue. If the queue is empty, the actions will begin being called immediately until the queue is exhausted. Further actions may be added during execution which will be executed once the preceding actions are exhausted.

Example:

const action_a = () => { console.log('action a') };
const action_b = () => { console.log('action b') };

enqueue_store_signals([
    action_a,
    action_b
]);

// > action a
// > action b

Example with nesting:

enqueue_store_signals([
    () => { console.log("action 1") },
    () => {
        console.log("action 2");
        enqueue_store_signals([
            () => { console.log("action 5") },
            () => { console.log("action 6") }
        ]);
        console.log("action 3");
    },
    () => { console.log("action 4") },
]);

// > action 1
// > action 2
// > action 3
// > action 4
// > action 5
// > action 6

Example Exception Handling:

const original_runner = set_store_runner(create_store_runner_log_errors(console.error));
try {
    enqueue_store_signals([
        () => {
            throw new Error('error 1');
        },
        () => {
            throw new Error('error 2');
        },
        () => {
            throw new Error('error 3');
        }
    ]);

    console.log('done.');

    // > Error: error 1
    // > Error: error 2
    // > Error: error 3
    // > done.
} finally {
    set_store_runner(original_runner);
}