Skip to content

Instantly share code, notes, and snippets.

View countcain's full-sized avatar
🏠
Working from home

Tao Huang countcain

🏠
Working from home
View GitHub Profile
@countcain
countcain / store.js
Last active September 8, 2022 15:21
Node 16 Async Storage
const {AsyncLocalStorage} = require('async_hooks')
const localStorage = new AsyncLocalStorage()
const sleep = () => new Promise(r=>setTimeout(r, 10))
const nestedFuncA = async () => {
await sleep()
const store = localStorage.getStore()
if (store) {