Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/singcl/thunk-run
🐔 A counterfeit simple basic co & comprehension of thunk function and function* in javascript.
https://github.com/singcl/thunk-run
co generator promisify promsie runner thunk thunkify
Last synced: 10 days ago
JSON representation
🐔 A counterfeit simple basic co & comprehension of thunk function and function* in javascript.
- Host: GitHub
- URL: https://github.com/singcl/thunk-run
- Owner: singcl
- Created: 2018-05-02T16:09:12.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-05-15T08:08:28.000Z (over 6 years ago)
- Last Synced: 2024-10-31T16:57:55.108Z (19 days ago)
- Topics: co, generator, promisify, promsie, runner, thunk, thunkify
- Language: JavaScript
- Homepage:
- Size: 187 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Thunkify Runner & Promisify Runner.
[![npm (scoped)](https://img.shields.io/npm/v/@singcl/thunk-run.svg?style=flat-square)](https://www.npmjs.com/package/@singcl/thunk-run)
![David](https://img.shields.io/david/dev/singcl/thunk-run.svg?style=flat-square)
![David](https://img.shields.io/david/singcl/thunk-run.svg?style=flat-square)
[![npm](https://img.shields.io/npm/dm/@singcl/thunk-run.svg?style=flat-square)](https://www.npmjs.com/package/@singcl/thunk-run)
![Github file size](https://img.shields.io/github/size/singcl/thunk-run/dist/bundle.min.js.svg?style=flat-square)### Usage
#### `await` along with Thunkify function.
```js
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.
```js
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`包可以直接使用。