mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-02 22:41:31 +01:00
git multirepo stage
This commit is contained in:
@@ -56,7 +56,7 @@ export function done<T>(promise: Promise<T>): Promise<void> {
|
||||
return promise.then<void>(() => void 0);
|
||||
}
|
||||
|
||||
export function once<T>(event: Event<T>): Event<T> {
|
||||
export function onceEvent<T>(event: Event<T>): Event<T> {
|
||||
return (listener, thisArgs = null, disposables?) => {
|
||||
const result = event(e => {
|
||||
result.dispose();
|
||||
@@ -68,7 +68,19 @@ export function once<T>(event: Event<T>): Event<T> {
|
||||
}
|
||||
|
||||
export function eventToPromise<T>(event: Event<T>): Promise<T> {
|
||||
return new Promise<T>(c => once(event)(c));
|
||||
return new Promise<T>(c => onceEvent(event)(c));
|
||||
}
|
||||
|
||||
export function once(fn: (...args: any[]) => any): (...args: any[]) => any {
|
||||
let didRun = false;
|
||||
|
||||
return (...args) => {
|
||||
if (didRun) {
|
||||
return;
|
||||
}
|
||||
|
||||
return fn(...args);
|
||||
};
|
||||
}
|
||||
|
||||
// TODO@Joao: replace with Object.assign
|
||||
|
||||
Reference in New Issue
Block a user