-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eclipse-che/che#9434 implement all editor objects (#28)
Signed-off-by: Yevhen Vydolob <yvydolob@redhat.com>
- Loading branch information
Showing
30 changed files
with
5,539 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
/* | ||
* Copyright (C) 2018 Red Hat, Inc. and others. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
|
||
// tslint:disable-next-line:no-any | ||
export function ok(val?: any, message?: string) { | ||
if (!val || val === null) { | ||
throw new Error(message ? `Assertion failed (${message})` : 'Assertion failed'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (C) 2018 Red Hat, Inc. and others. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
|
||
export interface Disposable { | ||
dispose(): void; | ||
} | ||
|
||
export function dispose<T extends Disposable>(disposable: T): T | undefined; | ||
export function dispose<T extends Disposable>(...disposables: T[]): T[] | undefined; | ||
export function dispose<T extends Disposable>(disposables: T[]): T[] | undefined; | ||
export function dispose<T extends Disposable>(first: T | T[], ...rest: T[]): T | T[] | undefined { | ||
if (Array.isArray(first)) { | ||
first.forEach(d => d && d.dispose()); | ||
return []; | ||
} else if (rest.length === 0) { | ||
if (first) { | ||
first.dispose(); | ||
return first; | ||
} | ||
return undefined; | ||
} else { | ||
dispose(first); | ||
dispose(rest); | ||
return []; | ||
} | ||
} |
Oops, something went wrong.