prex
Version:
Async coordination primitives and extensions on top of ES6 Promises
21 lines (19 loc) • 934 B
JavaScript
"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Licensed under the Apache License, Version 2.0.
See LICENSE file in the project root for details.
***************************************************************************** */
Object.defineProperty(exports, "__esModule", { value: true });
const cancellation_1 = require("./cancellation");
const cancelable_1 = require("@esfx/cancelable");
const utils_1 = require("./utils");
/*@internal*/
function getToken(token) {
if (utils_1.isMissing(token))
token = cancellation_1.CancellationToken.none;
if (!utils_1.isInstance(token, cancellation_1.CancellationToken) && !cancelable_1.Cancelable.hasInstance(token))
throw new TypeError("CancellationToken expected: token.");
return cancellation_1.CancellationToken.from(token);
}
exports.getToken = getToken;