Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

nodejs transofrm method into promise method

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)
})()
Comment

PREVIOUS NEXT
Code Example
Typescript :: download objects under a prefix in golang 
Typescript :: django query to return User whose first name starts with j or last name starts with h 
Typescript :: recharts direction 
Typescript :: acces arrey lements without comma 
Typescript :: Fragment no longer exists 
Typescript :: how to create instances of classes godot 
Typescript :: lofi hip hop beats cool 
Typescript :: ts date toisostring incorrect conversion 
Typescript :: bts assurance 
Typescript :: HTML form inputs to excel spreadsheet [duplicate] 
Typescript :: Restrict users to see only his own contacts odoo 
Typescript :: jest aliases typescript storybook 
Typescript :: how can i get 2 inputs in singal line seprated by space 
Typescript :: return type depends on input typescript 
Typescript :: nestjs called every X second method 
Typescript :: c code for insrting elements in set 
Typescript :: ts repeat string 
Typescript :: The State pattern allows an object to change its behavior when its internal state changes 
Typescript :: modify objects using dot notation 
Typescript :: how to pass node arguments in nextjs 
Typescript :: calling from a list elements in steps 
Typescript :: nest custom class validator 
Typescript :: reflect-metadata 
Typescript :: rest api django return value if exists in another table 
Cpp :: interpreter latex matlab 
Cpp :: if vector contains value c++ 
Cpp :: separation between paragraphs latex 
Cpp :: how to use winmain function 
Cpp :: c++ bold text 
Cpp :: c++ pause 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =