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 🙏

© 2026 – Pkg Stats / Ryan Hefner

sy-task

v0.0.4

Published

easy run sync or asyn task

Readme

sy-task

easy run sync or asyn task

install

npm install sy-task

run this project

npm run dev

then:
open in browser http://localhost:8888/pipeline.html
open in browser http://localhost:8888/queue.html

pipeline

Add three tasks to pipeline, they will run one by one. You can call next function to run next task that in pipeline.

// create a pipeline
// The data can be used in every task
let data = {};
let pipeline = new SYPipeline(data);

// The use method to add task to pipeline
// add sync task to pipeline, the task must a function that have (data, next) params
pipeline.use((data, next) => {
    doSomething();
    // run next task
    next();
});

// add async task to pipeline
pipeline.use((data, next) => {
    setTimeout(() => {
        // you can change data, add property taskId to data
        data.taskId = 'everydata';
        next();
    }, 200);
});

// add sync task to pipeline
pipeline.use(function (data, next) {
    if (data.taskId) {
        // find the task, stop run
    }
    else {
        next();
    }
});

// the task begin run
pipeline.run();

queue.race

Run task one by one, if the task resolve a truely value, the queue stop.

// a task
const everyDay = (data) => {
    return false;
};

const newUser = (data) => {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve('new user');
        }, 100);
    });
};

const vip = (data) => {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve('vip');
        }, 10);
    });
};

// create a SYQueue
let queue = new SYQueue();
// crate a task array
let tasks = [everyDay, newUser, vip];
// find the first resolve task
queue.race(tasks).then(res => {
    // the result is new user
    console.log('queue finished =', res);
}).catch(error => {
    console.log('error = ', error);
});

queue.serial

Run task one by one until all task finish.

// a task
const everyDay = (data) => {
    return false;
};

const newUser = (data) => {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve('new user');
        }, 100);
    });
};

const vip = (data) => {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve('vip');
        }, 10);
    });
};

// create a SYQueue
let queue = new SYQueue();
// crate a task array
let tasks = [everyDay, newUser, vip];
// run task one by one
queue.serial(tasks).then(res => {
    // res {
    //     0: false,
    //     1: new user,
    //     2: vip
    // }
    console.log('queue finished =', res);
}).catch(error => {
    console.log('error = ', error);
});

queue.parallel

Run task parallelly, you can set the value to limit how many task to run. One task will begin run when a task resolve. SYQueue will stop when all tasks finish.

// a task
const everyDay = (data) => {
    return false;
};

const newUser = (data) => {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve('new user');
        }, 100);
    });
};

const vip = (data) => {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve('vip');
        }, 10);
    });
};

// create a SYQueue
let queue = new SYQueue();
// crate a task array
let tasks = [everyDay, newUser, vip];
// only two tasks can run at a time
queue.parallel(tasks, 2).then(res => {
    // res {
    //     0: false,
    //     1: new user,
    //     2: vip
    // }
    console.log('queue finished =', res);
}).catch(error => {
    console.log('error = ', error);
});