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

yld

v1.2.0

Published

Forget your promises... adopt the yielded programming style

Downloads

42

Readme

yld

A JavaScript promises alternative, under the MIT License.

Concept :

yld (pronounced "yielded") is tool based on that keyword.

Contrary to promises, which grow to declare a lot of functions to disorganize your code, yld allows you to execute instructions written in a linear list.

Each yield pauses the process and allows to retrieve a response from another function ... could easily be compared to a promise.then().

The yld function :

var yielded = yld(closure);
yielded(/* closure arguments */);

The closure structure :

Create a step :

var closure;

closure = function () {
    yield; // this makes a step
};

Retrieve a response form an other scope :

var closure

closure = function () {
    var response;

    response = yield;
};

The closure properties :

Object this.parent

The parent yielded scope (parent.send() & parent.yld()), if current scope is created by this.yld(), else returns undefined

String set this.error()

Kills immediately the current process

var closure;

closure = function () {
    this.error = 'error message'; // throws the error message
    yield; // unreached point
};

Function this.send()

Send variables to the next yield response

var closure;

closure = function () {
    var response;

    this.send(123);
    response = yield; // response is 123
};

Function this.yld()

Your this context knows yld as internal method

var closure;

closure = function () {
    var yielded, response;
    
    yielded = this.yld(function (/* args */) {
        // here, the this.parent.send() is used to send a response to the parent scope
        this.parent.send(123);
    });
    
    response = yield yielded(/* args */); // response is 123
};

Requirements :

yield keyword support ES5 Object methods