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


TypeScript types.isUndefinedOrNull函數代碼示例

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


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

示例1: _cloneAndChange

function _cloneAndChange(obj: any, changer: (orig: any) => any, encounteredObjects: any[]): any {
	if (isUndefinedOrNull(obj)) {
		return obj;
	}

	const changed = changer(obj);
	if (typeof changed !== 'undefined') {
		return changed;
	}

	if (isArray(obj)) {
		const r1: any[] = [];
		for (let i1 = 0; i1 < obj.length; i1++) {
			r1.push(_cloneAndChange(obj[i1], changer, encounteredObjects));
		}
		return r1;
	}

	if (isObject(obj)) {
		if (encounteredObjects.indexOf(obj) >= 0) {
			throw new Error('Cannot clone recursive data-structure');
		}
		encounteredObjects.push(obj);
		const r2 = {};
		for (let i2 in obj) {
			if (_hasOwnProperty.call(obj, i2)) {
				(r2 as any)[i2] = _cloneAndChange(obj[i2], changer, encounteredObjects);
			}
		}
		encounteredObjects.pop();
		return r2;
	}

	return obj;
}
開發者ID:developers23,項目名稱:vscode,代碼行數:35,代碼來源:objects.ts

示例2: _cloneAndChange

function _cloneAndChange(obj: any, changer: (orig: any) => any, seen: Set<any>): any {
	if (isUndefinedOrNull(obj)) {
		return obj;
	}

	const changed = changer(obj);
	if (typeof changed !== 'undefined') {
		return changed;
	}

	if (isArray(obj)) {
		const r1: any[] = [];
		for (const e of obj) {
			r1.push(_cloneAndChange(e, changer, seen));
		}
		return r1;
	}

	if (isObject(obj)) {
		if (seen.has(obj)) {
			throw new Error('Cannot clone recursive data-structure');
		}
		seen.add(obj);
		const r2 = {};
		for (let i2 in obj) {
			if (_hasOwnProperty.call(obj, i2)) {
				(r2 as any)[i2] = _cloneAndChange(obj[i2], changer, seen);
			}
		}
		seen.delete(obj);
		return r2;
	}

	return obj;
}
開發者ID:PKRoma,項目名稱:vscode,代碼行數:35,代碼來源:objects.ts

示例3: test

	test('Properties', function () {
		const d = new Date().getTime();
		let s = createStat('/path/to/stat', 'sName', true, true, 8096, d);

		assert.strictEqual(s.isDirectoryResolved, false);
		assert.strictEqual(s.resource.fsPath, toResource('/path/to/stat').fsPath);
		assert.strictEqual(s.name, 'sName');
		assert.strictEqual(s.isDirectory, true);
		assert.strictEqual(s.mtime, new Date(d).getTime());
		assert.strictEqual(s.getChildrenArray().length, 0);

		s = createStat('/path/to/stat', 'sName', false, false, 8096, d);
		assert(isUndefinedOrNull(s.getChildrenArray()));
	});
開發者ID:jinlongchen2018,項目名稱:vscode,代碼行數:14,代碼來源:explorerModel.test.ts

示例4: test

	test("Properties", function() {
		let d = new Date().getTime();
		let s = createStat("/path/to/stat", "sName", true, true, 8096, d);

		assert.strictEqual(s.isDirectoryResolved, false);
		assert.strictEqual(s.resource.fsPath, toResource("/path/to/stat").fsPath);
		assert.strictEqual(s.name, "sName");
		assert.strictEqual(s.isDirectory, true);
		assert.strictEqual(s.hasChildren, true);
		assert.strictEqual(s.mtime, new Date(d).getTime());
		assert(isArray(s.children) && s.children.length === 0);

		s = createStat("/path/to/stat", "sName", false, false, 8096, d);
		assert(isUndefinedOrNull(s.children));
	});
開發者ID:578723746,項目名稱:vscode,代碼行數:15,代碼來源:viewModel.test.ts

示例5: contains

	/**
	 * Returns true if this change event contains the provided file with the given change type (if provided). In case of
	 * type DELETED, this method will also return true if a folder got deleted that is the parent of the
	 * provided file path.
	 */
	contains(resource: URI, type?: FileChangeType): boolean {
		if (!resource) {
			return false;
		}

		const checkForChangeType = !isUndefinedOrNull(type);

		return this._changes.some(change => {
			if (checkForChangeType && change.type !== type) {
				return false;
			}

			// For deleted also return true when deleted folder is parent of target path
			if (change.type === FileChangeType.DELETED) {
				return isEqualOrParent(resource, change.resource, !isLinux /* ignorecase */);
			}

			return isEqual(resource, change.resource, !isLinux /* ignorecase */);
		});
	}
開發者ID:fly-fisher,項目名稱:vscode,代碼行數:25,代碼來源:files.ts

示例6: test

	test('isUndefinedOrNull', () => {
		assert(!types.isUndefinedOrNull('foo'));
		assert(!types.isUndefinedOrNull([]));
		assert(!types.isUndefinedOrNull([1, 2, '3']));
		assert(!types.isUndefinedOrNull(true));
		assert(!types.isUndefinedOrNull({}));
		assert(!types.isUndefinedOrNull(/test/));
		assert(!types.isUndefinedOrNull(new RegExp('')));
		assert(!types.isUndefinedOrNull(new Date()));
		assert(!types.isUndefinedOrNull(assert));
		assert(!types.isUndefinedOrNull(function foo() { /**/ }));
		assert(!types.isUndefinedOrNull({ foo: 'bar' }));

		assert(types.isUndefinedOrNull(undefined));
		assert(types.isUndefinedOrNull(null));
	});
開發者ID:DonJayamanne,項目名稱:vscode,代碼行數:16,代碼來源:types.test.ts

示例7: isFileOperationError

	static isFileOperationError(obj: any): obj is FileOperationError {
		return obj instanceof Error && !isUndefinedOrNull((obj as FileOperationError).fileOperationResult);
	}
開發者ID:igolskyi,項目名稱:vscode,代碼行數:3,代碼來源:files.ts

示例8: isTextFileOperationError

	static isTextFileOperationError(obj: unknown): obj is TextFileOperationError {
		return obj instanceof Error && !isUndefinedOrNull((obj as TextFileOperationError).textFileOperationResult);
	}
開發者ID:eamodio,項目名稱:vscode,代碼行數:3,代碼來源:textfiles.ts

示例9: test

	test('does parse condition right', () => {
		let insightsDialogModel = new InsightsDialogModel();

		let label: IInsightsLabel = {
			column: undefined,
			state: [
				{
					condition: {
						if: 'always'
					},
					color: 'green'
				}
			]
		} as IInsightsLabel;
		insightsDialogModel.insight = { label } as IInsightsConfigDetails;
		insightsDialogModel.rows = [
			['label1', 'value1'],
			['label2', 'value2'],
			['label3', 'value3']
		];
		let result = insightsDialogModel.getListResources(0, 1);
		for (let resource of result) {
			assert.equal(resource.stateColor, 'green', 'always Condition did not return val as expected');
		}

		label.state = [
			{
				condition: {
					if: 'equals',
					equals: 'specific value'
				},
				color: 'green'
			}
		];

		insightsDialogModel.insight = { label } as IInsightsConfigDetails;
		insightsDialogModel.rows = [
			['label1', 'specific value'],
			['label2', 'value2'],
			['label3', 'value3']
		];
		result = insightsDialogModel.getListResources(0, 1);
		assert.equal(result[0].stateColor, 'green', 'always Condition did not return val as expected');
		assert.equal(isUndefinedOrNull(result[1].stateColor), true, 'always Condition did not return val as expected');
		assert.equal(isUndefinedOrNull(result[2].stateColor), true, 'always Condition did not return val as expected');

		label.state = [
			{
				condition: {
					if: 'equals',
					equals: 'specific value'
				},
				color: 'green'
			},
			{
				condition: {
					if: 'equals',
					equals: 'specific value2'
				},
				color: 'red'
			}
		];

		insightsDialogModel.insight = { label } as IInsightsConfigDetails;
		insightsDialogModel.rows = [
			['label1', 'specific value'],
			['label2', 'specific value2'],
			['label3', 'value3']
		];
		result = insightsDialogModel.getListResources(0, 1);
		assert.equal(result[0].stateColor, 'green', 'always Condition did not return val as expected');
		assert.equal(result[1].stateColor, 'red', 'always Condition did not return val as expected');
		assert.equal(isUndefinedOrNull(result[2].stateColor), true, 'always Condition did not return val as expected');

		label.state = [
			{
				condition: {
					if: 'greaterThan',
					equals: '2'
				},
				color: 'green'
			},
			{
				condition: {
					if: 'equals',
					equals: 'specific value2'
				},
				color: 'red'
			}
		];

		insightsDialogModel.insight = { label } as IInsightsConfigDetails;
		insightsDialogModel.rows = [
			['label1', '3'],
			['label2', 'specific value2'],
			['label3', 'value3']
		];
		result = insightsDialogModel.getListResources(0, 1);
		assert.equal(result[0].stateColor, 'green', 'always Condition did not return val as expected');
		assert.equal(result[1].stateColor, 'red', 'always Condition did not return val as expected');
//.........這裏部分代碼省略.........
開發者ID:AlexxNica,項目名稱:sqlopsstudio,代碼行數:101,代碼來源:insightsDialogModel.test.ts


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