NodeJS TransOfRM Metode menjadi metode janji
import path from 'path'
async function resolveAsync(...pathSegments: string[]): Promise<string> {
const resolve: any = await Promise.resolve(path.resolve)
return resolve(...pathSegments)
}
;(async () => {
// sync version
const dirSync: string = path.resolve('index.txt')
console.log(dirSync)
// async version
const asyncDir: string = await resolveAsync('index.txt')
console.log(asyncDir)
})()
Restu Wahyu Saputra