本文整理汇总了TypeScript中vs/base/common/types.isBoolean函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isBoolean函数的具体用法?TypeScript isBoolean怎么用?TypeScript isBoolean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isBoolean函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getProxyAgent
export async function getProxyAgent(rawRequestURL: string, options: IOptions = {}): Promise<Agent> {
const requestURL = parseUrl(rawRequestURL);
const proxyURL = options.proxyUrl || getSystemProxyURI(requestURL);
if (!proxyURL) {
return null;
}
const proxyEndpoint = parseUrl(proxyURL);
if (!/^https?:$/.test(proxyEndpoint.protocol || '')) {
return null;
}
const opts = {
host: proxyEndpoint.hostname || '',
port: Number(proxyEndpoint.port),
auth: proxyEndpoint.auth,
rejectUnauthorized: isBoolean(options.strictSSL) ? options.strictSSL : true
};
const Ctor = requestURL.protocol === 'http:'
? await import('http-proxy-agent')
: await import('https-proxy-agent');
return new Ctor(opts);
}
示例2: getBooleanValueFromStringOrBoolean
export function getBooleanValueFromStringOrBoolean(value: any): boolean {
if (types.isBoolean(value)) {
return value;
} else if (types.isString(value)) {
return value.toLowerCase() === 'true';
}
return false;
}
示例3: parseUrl
return new Promise<IRequestContext>((c, e) => {
const endpoint = parseUrl(options.url!);
const opts: https.RequestOptions = {
hostname: endpoint.hostname,
port: endpoint.port ? parseInt(endpoint.port) : (endpoint.protocol === 'https:' ? 443 : 80),
protocol: endpoint.protocol,
path: endpoint.path,
method: options.type || 'GET',
headers: options.headers,
agent: options.agent,
rejectUnauthorized: isBoolean(options.strictSSL) ? options.strictSSL : true
};
if (options.user && options.password) {
opts.auth = options.user + ':' + options.password;
}
req = rawRequest(opts, (res: http.IncomingMessage) => {
const followRedirects: number = isNumber(options.followRedirects) ? options.followRedirects : 3;
if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400 && followRedirects > 0 && res.headers['location']) {
request(assign({}, options, {
url: res.headers['location'],
followRedirects: followRedirects - 1
}), token).then(c, e);
} else {
let stream: Stream = res;
if (res.headers['content-encoding'] === 'gzip') {
stream = stream.pipe(createGunzip());
}
c({ res, stream } as IRequestContext);
}
});
req.on('error', e);
if (options.timeout) {
req.setTimeout(options.timeout);
}
if (options.data) {
if (typeof options.data === 'string') {
req.write(options.data);
} else {
options.data.pipe(req);
return;
}
}
req.end();
token.onCancellationRequested(() => {
req.abort();
e(canceled());
});
});
示例4: handleCommand
function handleCommand(tab: IDashboardTabContrib, extension: IExtensionPointUser<any>) {
let { description, container, provider, title, when, id, alwaysShow, isHomeTab } = tab;
// If always show is not specified, set it to true by default.
if (!types.isBoolean(alwaysShow)) {
alwaysShow = true;
}
let publisher = extension.description.publisher;
if (!title) {
extension.collector.error(localize('dashboardTab.contribution.noTitleError', 'No title specified for extension.'));
return;
}
if (!description) {
extension.collector.warn(localize('dashboardTab.contribution.noDescriptionWarning', 'No description specified to show.'));
}
if (!container) {
extension.collector.error(localize('dashboardTab.contribution.noContainerError', 'No container specified for extension.'));
return;
}
if (!provider) {
// Use a default. Consider warning extension developers about this in the future if in development mode
provider = Constants.mssqlProviderName;
// Cannot be a home tab if it did not specify a provider
isHomeTab = false;
}
if (Object.keys(container).length !== 1) {
extension.collector.error(localize('dashboardTab.contribution.moreThanOneDashboardContainersError', 'Exactly 1 dashboard container must be defined per space'));
return;
}
let result = true;
let containerkey = Object.keys(container)[0];
let containerValue = Object.values(container)[0];
switch (containerkey) {
case WIDGETS_CONTAINER:
result = validateWidgetContainerContribution(extension, containerValue);
break;
case GRID_CONTAINER:
result = validateGridContainerContribution(extension, containerValue);
break;
case NAV_SECTION:
result = validateNavSectionContributionAndRegisterIcon(extension, containerValue);
break;
}
if (result) {
registerTab({ description, title, container, provider, when, id, alwaysShow, publisher, isHomeTab });
}
}
示例5: parseUrl
return new TPromise<IRequestContext>(async (c, e) => {
const endpoint = parseUrl(options.url);
const rawRequest = options.getRawRequest
? options.getRawRequest(options)
: await getNodeRequest(options);
const opts: https.RequestOptions = {
hostname: endpoint.hostname,
port: endpoint.port ? parseInt(endpoint.port) : (endpoint.protocol === 'https:' ? 443 : 80),
protocol: endpoint.protocol,
path: endpoint.path,
method: options.type || 'GET',
headers: options.headers,
agent: options.agent,
rejectUnauthorized: isBoolean(options.strictSSL) ? options.strictSSL : true
};
if (options.user && options.password) {
opts.auth = options.user + ':' + options.password;
}
req = rawRequest(opts, (res: http.ClientResponse) => {
const followRedirects = isNumber(options.followRedirects) ? options.followRedirects : 3;
if (res.statusCode >= 300 && res.statusCode < 400 && followRedirects > 0 && res.headers['location']) {
request(assign({}, options, {
url: res.headers['location'],
followRedirects: followRedirects - 1
})).done(c, e);
} else {
let stream: Stream = res;
if (res.headers['content-encoding'] === 'gzip') {
stream = stream.pipe(createGunzip());
}
c({ res, stream });
}
});
req.on('error', e);
if (options.timeout) {
req.setTimeout(options.timeout);
}
if (options.data) {
req.write(options.data);
}
req.end();
},
示例6: getProxyAgent
export function getProxyAgent(rawRequestURL: string, options: IOptions = {}): any {
const requestURL = parseUrl(rawRequestURL);
const proxyURL = options.proxyUrl || getSystemProxyURI(requestURL);
if (!proxyURL) {
return null;
}
const proxyEndpoint = parseUrl(proxyURL);
if (!/^https?:$/.test(proxyEndpoint.protocol)) {
return null;
}
const opts = {
host: proxyEndpoint.hostname,
port: Number(proxyEndpoint.port),
auth: proxyEndpoint.auth,
rejectUnauthorized: isBoolean(options.strictSSL) ? options.strictSSL : true
};
return requestURL.protocol === 'http:' ? new HttpProxyAgent(opts) : new HttpsProxyAgent(opts);
}