當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript comparers.compareFileNames函數代碼示例

本文整理匯總了TypeScript中vs/base/common/comparers.compareFileNames函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript compareFileNames函數的具體用法?TypeScript compareFileNames怎麽用?TypeScript compareFileNames使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了compareFileNames函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: test

	test('compareFileNames', () => {

		assert(compareFileNames('', '') === 0, 'empty should be equal');
		assert(compareFileNames('abc', 'abc') === 0, 'equal names should be equal');
		assert(compareFileNames('.abc', '.abc') === 0, 'equal full names should be equal');
		assert(compareFileNames('.env', '.env.example') < 0);
		assert(compareFileNames('.env.example', '.gitattributes') < 0);
	});
開發者ID:StateFarmIns,項目名稱:vscode,代碼行數:8,代碼來源:comparers.test.ts

示例2: test

	test('compareFileNames', () => {

		// Setup Intl
		setFileNameComparer(new IdleValue(() => {
			const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' });
			return {
				collator: collator,
				collatorIsNumeric: collator.resolvedOptions().numeric
			};
		}));

		assert(compareFileNames(null, null) === 0, 'null should be equal');
		assert(compareFileNames(null, 'abc') < 0, 'null should be come before real values');
		assert(compareFileNames('', '') === 0, 'empty should be equal');
		assert(compareFileNames('abc', 'abc') === 0, 'equal names should be equal');
		assert(compareFileNames('.abc', '.abc') === 0, 'equal full names should be equal');
		assert(compareFileNames('.env', '.env.example') < 0, 'filenames with extensions should come after those without');
		assert(compareFileNames('.env.example', '.gitattributes') < 0, 'filenames starting with dots and with extensions should still sort properly');
		assert(compareFileNames('1', '1') === 0, 'numerically equal full names should be equal');
		assert(compareFileNames('abc1.txt', 'abc1.txt') === 0, 'equal filenames with numbers should be equal');
		assert(compareFileNames('abc1.txt', 'abc2.txt') < 0, 'filenames with numbers should be in numerical order, not alphabetical order');
		assert(compareFileNames('abc2.txt', 'abc10.txt') < 0, 'filenames with numbers should be in numerical order even when they are multiple digits long');
	});
開發者ID:KTXSoftware,項目名稱:KodeStudio,代碼行數:23,代碼來源:comparers.test.ts


注:本文中的vs/base/common/comparers.compareFileNames函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。