• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript strings.startsWith函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中vs/base/common/strings.startsWith函数的典型用法代码示例。如果您正苦于以下问题:TypeScript startsWith函数的具体用法?TypeScript startsWith怎么用?TypeScript startsWith使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了startsWith函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: rgErrorMsgForDisplay

export function rgErrorMsgForDisplay(msg: string): string | undefined {
	const lines = msg.trim().split('\n');
	const firstLine = lines[0].trim();

	if (strings.startsWith(firstLine, 'Error parsing regex')) {
		return firstLine;
	}

	if (strings.startsWith(firstLine, 'regex parse error')) {
		return strings.uppercaseFirstLetter(lines[lines.length - 1].trim());
	}

	if (strings.startsWith(firstLine, 'error parsing glob') ||
		strings.startsWith(firstLine, 'unsupported encoding')) {
		// Uppercase first letter
		return firstLine.charAt(0).toUpperCase() + firstLine.substr(1);
	}

	if (firstLine === `Literal '\\n' not allowed.`) {
		// I won't localize this because none of the Ripgrep error messages are localized
		return `Literal '\\n' currently not supported`;
	}

	if (strings.startsWith(firstLine, 'Literal ')) {
		// Other unsupported chars
		return firstLine;
	}

	return undefined;
}
开发者ID:KTXSoftware,项目名称:KodeStudio,代码行数:30,代码来源:fileSearch.ts


示例2: trimTrailingSlash

		.forEach(key => {
			if (excludesToSkip && excludesToSkip.has(key)) {
				return;
			}

			if (!key) {
				return;
			}

			const value = patterns[key];
			key = trimTrailingSlash(folder ? getAbsoluteGlob(folder, key) : key);

			// glob.ts requires forward slashes, but a UNC path still must start with \\
			// #38165 and #38151
			if (strings.startsWith(key, '\\\\')) {
				key = '\\\\' + key.substr(2).replace(/\\/g, '/');
			} else {
				key = key.replace(/\\/g, '/');
			}

			if (typeof value === 'boolean' && value) {
				if (strings.startsWith(key, '\\\\')) {
					// Absolute globs UNC paths don't work properly, see #58758
					key += '**';
				}

				globArgs.push(fixDriveC(key));
			} else if (value && value.when) {
				if (!siblingClauses) {
					siblingClauses = {};
				}

				siblingClauses[key] = value;
			}
		});
开发者ID:DonJayamanne,项目名称:vscode,代码行数:35,代码来源:ripgrepFileSearch.ts


示例3: resolveContent

	contents.session.protocol.registerBufferProtocol(protocol, (request, callback: any) => {
		if (extensionLocation && extensionLocation.scheme === REMOTE_HOST_SCHEME) {
			const requestUri = URI.parse(request.url);
			const redirectedUri = URI.from({
				scheme: REMOTE_HOST_SCHEME,
				authority: extensionLocation.authority,
				path: '/vscode-resource',
				query: JSON.stringify({
					requestResourcePath: requestUri.path
				})
			});
			resolveContent(fileService, redirectedUri, getMimeType(requestUri), callback);
			return;
		}

		const requestPath = URI.parse(request.url).path;
		const normalizedPath = URI.file(requestPath);
		for (const root of getRoots()) {
			if (startsWith(normalizedPath.fsPath, root.fsPath + sep)) {
				resolveContent(fileService, normalizedPath, getMimeType(normalizedPath), callback);
				return;
			}
		}
		console.error('Webview: Cannot load resource outside of protocol root');
		callback({ error: -10 /* ACCESS_DENIED: https://cs.chromium.org/chromium/src/net/base/net_error_list.h */ });
	}, (error) => {
开发者ID:joelday,项目名称:vscode,代码行数:26,代码来源:webviewProtocols.ts


示例4: assertResolve

	function assertResolve(u1: URI, path: string, expected: URI) {
		const actual = resolvePath(u1, path);
		assertEqualURI(actual, expected, `from ${u1.toString()} and ${path}`);

		if (!isAbsolute(path)) {
			let expectedPath = isWindows ? toSlashes(path) : path;
			expectedPath = startsWith(expectedPath, './') ? expectedPath.substr(2) : expectedPath;
			assert.equal(relativePath(u1, actual), expectedPath, `relativePath (${u1.toString()}) on actual (${actual.toString()}) should be to path (${expectedPath})`);
		}
	}
开发者ID:eamodio,项目名称:vscode,代码行数:10,代码来源:resources.test.ts


示例5: if

		services.forEach((service, index) => {
			let expectedKeyCount = 4;
			let storageToTest;

			const workspaceId = workspaceIds[index];
			if (startsWith(workspaceId, 'file:')) {
				storageToTest = parsed.folder.get(workspaceId);
				expectedKeyCount++; // workspaceIdentifier gets added!
			} else if (startsWith(workspaceId, 'empty:')) {
				storageToTest = parsed.empty.get(workspaceId);
			} else if (startsWith(workspaceId, 'root:')) {
				storageToTest = parsed.multiRoot.get(workspaceId);
			}

			assert.equal(Object.keys(storageToTest).length, expectedKeyCount);
			assert.equal(storageToTest['key1'], service.get('key1', StorageScope.WORKSPACE));
			assert.equal(storageToTest['key2.something'], service.get('key2.something', StorageScope.WORKSPACE));
			assert.equal(storageToTest['key3/special'], service.get('key3/special', StorageScope.WORKSPACE));
			assert.equal(storageToTest['key4 space'], service.get('key4 space', StorageScope.WORKSPACE));
		});
开发者ID:ramesius,项目名称:vscode,代码行数:20,代码来源:migration.test.ts


示例6:

		activeKeys.forEach(key => {
			if (!startsWith(key, workspace.prefix)) {
				return; // not part of workspace prefix or already handled
			}

			activeKeys.delete(key);

			if (workspace.resource === folderId) {
				// storage://workspace/<folder>/someKey => someKey
				const storageKey = key.substr(workspace.prefix.length);
				folderWorkspaceStorage[storageKey] = storage.getItem(key);
			}
		});
开发者ID:,项目名称:,代码行数:13,代码来源:


示例7: compareByPrefix

export function compareByPrefix(one: string, other: string, lookFor: string): number {
	let elementAName = one.toLowerCase();
	let elementBName = other.toLowerCase();

	// Sort prefix matches over non prefix matches
	let elementAPrefixMatch = strings.startsWith(elementAName, lookFor);
	let elementBPrefixMatch = strings.startsWith(elementBName, lookFor);
	if (elementAPrefixMatch !== elementBPrefixMatch) {
		return elementAPrefixMatch ? -1 : 1;
	}

	// Same prefix: Sort shorter matches to the top to have those on top that match more precisely
	else if (elementAPrefixMatch && elementBPrefixMatch) {
		if (elementAName.length < elementBName.length) {
			return -1;
		}

		if (elementAName.length > elementBName.length) {
			return 1;
		}
	}

	return 0;
}
开发者ID:VishalMadhvani,项目名称:vscode,代码行数:24,代码来源:comparers.ts


示例8: parseMultiRootStorage

export function parseMultiRootStorage(storage: IStorageLegacy, targetWorkspaceId: string): StorageObject {
	const multiRootStoragePrefix = `${COMMON_WORKSPACE_PREFIX}${targetWorkspaceId}/`;

	const multiRootWorkspaceStorage: StorageObject = Object.create(null);
	for (let i = 0; i < storage.length; i++) {
		const key = storage.key(i);

		if (startsWith(key, multiRootStoragePrefix) && !endsWith(key, StorageLegacyService.WORKSPACE_IDENTIFIER)) {
			// storage://workspace/root:<id>/someKey => someKey
			multiRootWorkspaceStorage[key.substr(multiRootStoragePrefix.length)] = storage.getItem(key);
		}
	}

	return multiRootWorkspaceStorage;
}
开发者ID:,项目名称:,代码行数:15,代码来源:


示例9: tab

	public static tab(config: CursorConfiguration, model: ITokenizedModel, cursors: SingleCursorState[]): EditOperationResult {
		let commands: CommandResult[] = [];
		for (let i = 0, len = cursors.length; i < len; i++) {
			const cursor = cursors[i];
			let selection = cursor.selection;

			if (selection.isEmpty()) {

				let lineText = model.getLineContent(selection.startLineNumber);

				if (/^\s*$/.test(lineText)) {
					let goodIndent = this._goodIndentForLine(config, model, selection.startLineNumber);
					goodIndent = goodIndent || '\t';
					let possibleTypeText = config.normalizeIndentation(goodIndent);
					if (!strings.startsWith(lineText, possibleTypeText)) {
						let command = new ReplaceCommand(new Range(selection.startLineNumber, 1, selection.startLineNumber, lineText.length + 1), possibleTypeText);
						commands[i] = new CommandResult(command, true);
						continue;
					}
				}

				commands[i] = new CommandResult(this._replaceJumpToNextIndent(config, model, selection), true);
			} else {
				if (selection.startLineNumber === selection.endLineNumber) {
					let lineMaxColumn = model.getLineMaxColumn(selection.startLineNumber);
					if (selection.startColumn !== 1 || selection.endColumn !== lineMaxColumn) {
						// This is a single line selection that is not the entire line
						commands[i] = new CommandResult(this._replaceJumpToNextIndent(config, model, selection), false);
						continue;
					}
				}

				commands[i] = new CommandResult(
					new ShiftCommand(selection, {
						isUnshift: false,
						tabSize: config.tabSize,
						oneIndent: config.oneIndent,
						useTabStops: config.useTabStops
					}),
					false
				);
			}
		}
		return new EditOperationResult(commands, {
			shouldPushStackElementBefore: true,
			shouldPushStackElementAfter: true
		});
	}
开发者ID:wangcheng678,项目名称:vscode,代码行数:48,代码来源:cursorTypeOperations.ts


示例10: parseNoWorkspaceStorage

export function parseNoWorkspaceStorage(storage: IStorageLegacy) {
	const noWorkspacePrefix = `${StorageLegacyService.WORKSPACE_PREFIX}__$noWorkspace__`;

	const noWorkspaceStorage: StorageObject = Object.create(null);
	for (let i = 0; i < storage.length; i++) {
		const key = storage.key(i);

		// No Workspace key is for extension development windows
		if (startsWith(key, noWorkspacePrefix) && !endsWith(key, StorageLegacyService.WORKSPACE_IDENTIFIER)) {
			// storage://workspace/__$noWorkspace__someKey => someKey
			noWorkspaceStorage[key.substr(NO_WORKSPACE_PREFIX.length)] = storage.getItem(key);
		}
	}

	return noWorkspaceStorage;
}
开发者ID:,项目名称:,代码行数:16,代码来源:



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript strings.startsWithIgnoreCase函数代码示例发布时间:2022-05-25
下一篇:
TypeScript strings.rtrim函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap