UNPKG

934 BJavaScriptView Raw
1"use strict";
2/*! *****************************************************************************
3Copyright (c) Microsoft Corporation.
4Licensed under the Apache License, Version 2.0.
5
6See LICENSE file in the project root for details.
7***************************************************************************** */
8Object.defineProperty(exports, "__esModule", { value: true });
9const cancellation_1 = require("./cancellation");
10const cancelable_1 = require("@esfx/cancelable");
11const utils_1 = require("./utils");
12/*@internal*/
13function getToken(token) {
14 if (utils_1.isMissing(token))
15 token = cancellation_1.CancellationToken.none;
16 if (!utils_1.isInstance(token, cancellation_1.CancellationToken) && !cancelable_1.Cancelable.hasInstance(token))
17 throw new TypeError("CancellationToken expected: token.");
18 return cancellation_1.CancellationToken.from(token);
19}
20exports.getToken = getToken;