Move toPromise to its own file

pull/13/head
Kelvin Schoofs 7 years ago
parent b276fc9cba
commit fe9b6b5041

@ -2,6 +2,7 @@
import { Client, ConnectConfig } from 'ssh2';
import * as vscode from 'vscode';
import SSHFileSystem, { EMPTY_FILE_SYSTEM } from './sshFileSystem';
import { toPromise } from './toPromise';
async function assertFs(man: Manager, uri: vscode.Uri) {
const fs = await man.getFs(uri);

@ -4,12 +4,7 @@ import * as ssh2 from 'ssh2';
import * as ssh2s from 'ssh2-streams';
import * as vscode from 'vscode';
type toPromiseCallback<T> = (err: Error | null, res?: T) => void;
async function toPromise<T>(func: (cb: toPromiseCallback<T>) => void): Promise<T> {
return new Promise<T>((resolve, reject) => {
func((err, res) => err ? reject(err) : resolve(res));
});
}
import { toPromise } from './toPromise';
export class SSHFileSystem implements vscode.FileSystemProvider {
public copy = undefined;

@ -0,0 +1,7 @@
export type toPromiseCallback<T> = (err: Error | null, res?: T) => void;
export async function toPromise<T>(func: (cb: toPromiseCallback<T>) => void): Promise<T> {
return new Promise<T>((resolve, reject) => {
func((err, res) => err ? reject(err) : resolve(res));
});
}
Loading…
Cancel
Save