Coder Social home page Coder Social logo

singcl / thunk-run Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 191 KB

🐔 A counterfeit simple basic co & comprehension of thunk function and function* in javascript.

JavaScript 61.34% TypeScript 38.66%
thunk thunkify generator runner promsie promisify co

thunk-run's Introduction

Thunkify Runner & Promisify Runner.

npm (scoped) David David npm Github file size

Usage

await along with Thunkify function.

var fs = require("fs");
var path = require("path");

var thunkify = require("@singcl/thunk-run").thunkify;
var thunkifyRun = require("@singcl/thunk-run").thunkifyRun;

var reaFileThunkify = thunkify(fs.readFile);
var filePath = path.resolve(__dirname, "../package.json");

// Generator Thunk自动执行器单独为一个thunkifyRun 模块

function* gen() {
    try {
        var r1 = yield reaFileThunkify(filePath, "utf8");
        console.log(r1);
        var r2 = yield reaFileThunkify(filePath, "utf8");
        console.log(r2);
    } catch (error) {
        console.log("Generator内捕获错误:", error);
    }
}

thunkifyRun(gen);

await along with Promisify function.

var fs = require("fs");
var path = require("path");

var promisify = require("@singcl/thunk-run").promisify;
var promisifyRun = require("@singcl/thunk-run").promisifyRun;

var reaFilePromisify = promisify(fs.readFile);
var filePath = path.resolve(__dirname, "../example/test.txt");

// Generator Promise 自动执行器单独为一个 promisifyRun 模块

function* gen() {
    try {
        var r1 = yield reaFilePromisify(filePath, "utf8");
        console.log(r1);
        var r2 = yield reaFilePromisify(filePath, "utf8");
        console.log(r2);
    } catch (error) {
        console.log("Generator内捕获错误:", error);
    }
}

promisifyRun(gen);

UMD

在dist目录下已经构建好了UMD包可以直接使用。

thunk-run's People

Contributors

singcl avatar

Watchers

 avatar  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.