当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript types.isBoolean函数代码示例

本文整理汇总了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);
}
开发者ID:DonJayamanne,项目名称:vscode,代码行数:27,代码来源:proxy.ts

示例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;
}
开发者ID:burhandodhy,项目名称:azuredatastudio,代码行数:8,代码来源:dialogHelper.ts

示例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());
			});
		});
开发者ID:donaldpipowitch,项目名称:vscode,代码行数:58,代码来源:request.ts

示例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 });
		}
	}
开发者ID:burhandodhy,项目名称:azuredatastudio,代码行数:54,代码来源:dashboardTab.contribution.ts

示例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();
	},
开发者ID:Chan-PH,项目名称:vscode,代码行数:52,代码来源:request.ts

示例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);
}
开发者ID:sangohan,项目名称:KodeStudio,代码行数:23,代码来源:proxy.ts


注:本文中的vs/base/common/types.isBoolean函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。