提交 83c6ebda 编写于 作者: J Johannes Rieken

debt - improve isCancellationToken

上级 bef577c1
......@@ -25,12 +25,15 @@ const shortcutEvent = Object.freeze(function (callback, context?): IDisposable {
export namespace CancellationToken {
export function isCancellationToken(thing: any): thing is CancellationToken {
if (!thing || typeof thing !== 'object') {
return false;
if (thing === CancellationToken.None || thing === CancellationToken.Cancelled) {
return true;
}
if (thing instanceof MutableToken) {
return true;
}
if (!thing || typeof thing !== 'object') {
return false;
}
return typeof (thing as CancellationToken).isCancellationRequested === 'boolean'
&& typeof (thing as CancellationToken).onCancellationRequested === 'function';
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册