Use undefined instead of null
This commit is contained in:
parent
1beb153f21
commit
5a0c06473c
1 changed files with 5 additions and 5 deletions
|
@ -15,8 +15,8 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export class Lock {
|
export class Lock {
|
||||||
private _promise: Promise<void> | null = null;
|
private _promise?: Promise<void>;
|
||||||
private _resolve: (() => void) | null = null;
|
private _resolve?: (() => void);
|
||||||
|
|
||||||
tryTake(): boolean {
|
tryTake(): boolean {
|
||||||
if (!this._promise) {
|
if (!this._promise) {
|
||||||
|
@ -40,14 +40,14 @@ export class Lock {
|
||||||
|
|
||||||
release(): void {
|
release(): void {
|
||||||
if (this._resolve) {
|
if (this._resolve) {
|
||||||
this._promise = null;
|
this._promise = undefined;
|
||||||
const resolve = this._resolve;
|
const resolve = this._resolve;
|
||||||
this._resolve = null;
|
this._resolve = undefined;
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
released(): Promise<void> | null {
|
released(): Promise<void> | undefined {
|
||||||
return this._promise;
|
return this._promise;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue