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

kyoo

v5.0.1

Published

Server/browser async queue based on jessetane/queue

Downloads

5

Readme

kyoo

Asynchronous function queue with adjustable concurrency.

This repo is based on original Queue implementation and completely re-writen using modern ES6 (you'll need Node 6.x+ or Babel to work with it).

npm tests coverage

Why "Kyoo"

Kyoo ("kyo͞o" actually) is a transcription of word "queue". Taken because all "queue" things were already used all over npm and github :)

Why

Async is a big library offering various approaches to dealing with asynchrony; kyoo is a small library offering a single, flexible abstraction.

How

This module exports a class Kyoo that implements most of the Array API. Pass async functions (ones that accept a callback) to an instance's additive array methods. Processing begins when you call q.start().

Install

npm install kyoo

Test

npm test npm run test-browser

Example

npm run example

var Kyoo = require('kyoo');

var q = new Kyoo();
var results = [];

// add jobs using the Array API

q.push(function(cb) {
  results.push('two');
  cb();
});

q.push(
  function(cb) {
    results.push('four');
    cb();
  },
  function(cb) {
    results.push('five');
    cb();
  }
);

q.unshift(function(cb) {
  results.push('one');
  cb();
});

q.splice(2, 0, function(cb) {
  results.push('three');
  cb();
});

// use the timeout feature to deal with jobs that
// take too long or forget to execute a callback

q.timeout = 100;

q.on('timeout', function(next, job) {
  console.log('job timed out:', job.toString().replace(/\n/g, ''));
  next();
});

q.push(function(cb) {
  setTimeout(function() {
    console.log('slow job finished');
    cb();
  }, 200);
});

q.push(function(cb) {
  console.log('forgot to execute callback');
});

// get notified when jobs complete

q.on('success', function(result, job) {
  console.log('job finished processing:', job.toString().replace(/\n/g, ''));
});

// begin processing, get notified on end / failure

q.start(function(err) {
  console.log('all done:', results);
});

Require

var Kyoo = require('kyoo')

Constructor

var q = new Kyoo([opts])

Where opts may contain inital values for:

  • q.concurrency
  • q.timeout

Instance methods

q.start([cb])

cb, if passed, will be called when the queue empties or when an error occurs.

q.stop()

Stops the queue. can be resumed with q.start().

q.end([err])

Stop and empty the queue immediately.

Instance methods mixed in from Array

Mozilla has docs on how these methods work here.

q.push(element1, ..., elementN)

q.unshift(element1, ..., elementN)

q.splice(index , howMany[, element1[, ...[, elementN]]])

q.pop()

q.shift()

q.slice(begin[, end])

q.reverse()

q.indexOf(searchElement[, fromIndex])

q.lastIndexOf(searchElement[, fromIndex])

Properties

q.autostart

Start queue right after adding functions to it, defaults to false.

q.concurrency

Max number of jobs the queue should process concurrently, defaults to Infinity.

q.timeout

Milliseconds to wait for a job to execute its callback.

q.length

Jobs pending + jobs to process (readonly).

Events

q.emit('success', result, job)

After a job executes its callback.

q.emit('error', err, job)

After a job passes an error to its callback.

q.emit('timeout', continue, job)

After q.timeout milliseconds have elapsed and a job has not executed its callback.

q.emit('end'[, err])

After all jobs have been processed

Releases

The latest stable release is published to npm. Abbreviated changelog below:

  • 5.0
    • Rewriten in ES6 and renamed (Queue => Kyoo)
  • 4.0
    • Change license to MIT
  • 3.1.x
    • Add .npmignore
  • 3.0.x
    • Change the default concurrency to Infinity
    • Allow q.start() to accept an optional callback executed on q.emit('end')
  • 2.x
    • Major api changes / not backwards compatible with 1.x
  • 1.x
    • Early prototype

License

Copyright © 2014 Jesse Tane [email protected] Copyright © 2016 Nicholas Strife [email protected]

This work is free. You can redistribute it and/or modify it under the terms of the MIT License. See LICENSE for full details.