Skip to content
Permalink
Browse files

refactor: Return promises directly rather than using async/await.

  • Loading branch information...
jackson-dean committed Nov 7, 2019
1 parent a916433 commit c017e68a58e29722f959add28aa96cc5e853487d
@@ -6,7 +6,7 @@
"author": "LinkedIn Corporation",
"license": "BSD-2-Clause",
"engines": {
"node": "10.11.0"
"node": "*"
},
"repository": {
"type": "git",
@@ -75,28 +75,20 @@ function maybeCompletionItem(completionCandidateInfo: PathCompletionCandidateInf
return null;
}

async function getFilesInDirectory(directoryPath: string): Promise<string[]> {
try {
return await new Promise((resolve, reject) => {
fs.readdir(directoryPath, (error, fileNames) => {
error ? reject(error) : resolve(fileNames);
});
function getFilesInDirectory(directoryPath: string): Promise<string[]> {
return new Promise((resolve) => {
fs.readdir(directoryPath, (error, fileNames) => {
error ? resolve([]) : resolve(fileNames);
});
} catch (e) {
return [];
}
});
}

async function getStatsForFile(filePath: string): Promise<fs.Stats | null> {
try {
return await new Promise((resolve, reject) => {
fs.stat(filePath, (error, stats) => {
error ? reject(error) : resolve(stats);
});
function getStatsForFile(filePath: string): Promise<fs.Stats | null> {
return new Promise((resolve) => {
fs.stat(filePath, (error, stats) => {
error ? resolve(null) : resolve(stats);
});
} catch (e) {
return null;
}
});
}

async function getImportPathCompletions(documentUri: string, relativeImportPath: string): Promise<CompletionItem[]> {

0 comments on commit c017e68

Please sign in to comment.
You can’t perform that action at this time.