【文件属性】:
文件名称:make-synchronous:使异步功能同步
文件大小:6KB
文件格式:ZIP
更新时间:2021-03-19 15:08:28
JavaScript
使同步
使异步功能同步
对于大多数任务,这是错误的工具!尽可能使用异步API。
与软件包 ,此软件包的好处是该软件包不是本机的Node.js插件(存在很多问题)。而是,此程序包在子进程中同步执行给定功能。
该软件包仅在Node.js中有效,而在浏览器中无效。
安装
$ npm install make-synchronous
用法
const makeSynchronous = require ( 'make-synchronous' ) ;
const fn = makeSynchronous ( async number => {
const delay = require ( 'delay' ) ;
await delay ( 100 ) ;
return number * 2 ;
} ) ;
console . log ( fn ( 2 ) ) ;
//=> 4
原料药
m
【文件预览】:
make-synchronous-main
----.gitignore(23B)
----package.json(850B)
----.npmrc(19B)
----index.js(1KB)
----test.js(614B)
----.github()
--------workflows()
--------funding.yml(91B)
----license(1KB)
----readme.md(2KB)
----index.test-d.ts(166B)
----.gitattributes(19B)
----.editorconfig(175B)
----index.d.ts(1KB)