TypeScript vs/platform/configuration/common/model toValuesTree示例

说明

typescript vs/platform/configuration/common/model tovaluestree示例是从最受好评的开源项目中提取的实现代码,你可以参考下面示例的使用方式。

编程语言: TypeScript

命名空间/包名称: vs/platform/configuration/common/model

示例#1

export function newConfigFile(value: string): IConfigFile {
	try {
		const contents = json.parse(value) || {};
		return {
			contents: toValuesTree(contents),
			raw: contents
		};
	} catch (e) {
		return {
			contents: {},
			parseError: e
		};
	}
}

示例#2
文件: model.ts 项目: StateFarmIns/vscode

export function newConfigFile(value: string, fileName: string): IConfigFile {
	try {
		const contents = json.parse(value) || {};
		return {
			contents: toValuesTree(contents, message => console.error(`Conflict in settings file ${fileName}: ${message}`)),
			raw: contents
		};
	} catch (e) {
		return {
			contents: {},
			parseError: e
		};
	}
}

展开阅读全文