Giter VIP home page Giter VIP logo

proms's Introduction

proms

Is this project finished ?

A Very Simple Promise Simulator for Old Browsers

NPM

"Why should I use it ?!!"

Because it works in any javascript standards, and it does'nt matter that your code is executed in old browsers or the new ones.

"What does it support ?!!"

It can only understand then, catch, and finally.

"How can I test it ?"

Here is an example which you can compare native Promise with this package ((proms)) in node.js:

"use strict";

const fs = require("fs");
const proms = require("proms");

console.log("======================== Use The JavaScript Built-in Promise");
logDirListPromise()
    .then(msg => console.error(`1. ${msg}`))
    .then(msg => console.log(`2. ${msg}`))
    .catch(msg => console.error(msg))
    .then(() => {

        console.log("======================== Then Use This Package");
        logDirListProms()
            .then(msg => console.error(`1. ${msg}`))
            .then(msg => console.log(`2. ${msg}`))
            .catch(msg => console.error(msg))
            .finally(msg /*message of resolve or reject*/ => {
                console.log(`The .finally() msg is => ${msg}`);
            });

    });


function logDirListPromise(){

    return new Promise((resolve, reject) => {

        fs.readdir("./", (err, files) => {
            if(err)
                return reject(err);
            files.forEach(elem => console.log(elem));
            resolve("Hello");
        });

    });

}

function logDirListProms(){

    return new proms((resolve, reject) => {

        fs.readdir("./", (err, files) => {
            if(err)
                return reject(err);
            files.forEach(elem => console.log(elem));
            resolve("Hello");
        });

    });

}

Wanna Learn The Usage of Promises ?

Here is a reference for those who want to learn promises, recently.

Contribution

Contribute with me, guys !

Help me close the current ((or the future)) issues together in github...

❤️ Thanks for using

proms's People

Contributors

smrsan avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.