sync_async:运行异步代码同步方式

时间:2021-04-07 01:07:29
【文件属性】:
文件名称:sync_async:运行异步代码同步方式
文件大小:8KB
文件格式:ZIP
更新时间:2021-04-07 01:07:29
TypeScript 运行异步代码以与工作程序和共享缓冲区同步 async function main ( ) { // allocate sync-async runner const runner = await createRunner ( 1024 ) ; const text = runner . run ( async ( ) => { return fetch ( 'https://jsonplaceholder.typicode.com/todos/1' ) . then ( x => x . json ( ) ) ; } , [ ] ) ; // we got result in sync way here! console . log ( text ) ; } Currenlty仅在浏览器中起作用。 要运行示例,请执行以下操作
【文件预览】:
sync_async-master
----src()
--------index.ts(7KB)
----lib()
--------index.html(124B)
----tsconfig.json(6KB)
----.gitignore(61B)
----readme.md(697B)
----package-lock.json(3KB)
----package.json(287B)

网友评论