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


TypeScript objects.deepClone函數代碼示例

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


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

示例1:

TaskDefinitionRegistry.onReady().then(() => {
	for (let taskType of TaskDefinitionRegistry.all()) {
		let schema: IJSONSchema = Objects.deepClone(taskConfiguration);
		const schemaProperties = schema.properties!;
		// Since we do this after the schema is assigned we need to patch the refs.
		schemaProperties.type = {
			type: 'string',
			description: nls.localize('JsonSchema.customizations.customizes.type', 'The task type to customize'),
			enum: [taskType.taskType]
		};
		if (taskType.required) {
			schema.required = taskType.required.slice();
		} else {
			schema.required = [];
		}
		// Customized tasks require that the task type be set.
		schema.required.push('type');
		if (taskType.properties) {
			for (let key of Object.keys(taskType.properties)) {
				let property = taskType.properties[key];
				schemaProperties[key] = Objects.deepClone(property);
			}
		}
		fixReferences(schema);
		taskDefinitions.push(schema);
	}
});
開發者ID:PKRoma,項目名稱:vscode,代碼行數:27,代碼來源:jsonSchema_v2.ts

示例2: getJsonSchema

	public getJsonSchema(): IJSONSchema {
		if (this._schema === void 0) {
			let schemas: IJSONSchema[] = [];
			for (let definition of this.all()) {
				let schema: IJSONSchema = {
					type: 'object',
					additionalProperties: false
				};
				if (definition.required.length > 0) {
					schema.required = definition.required.slice(0);
				}
				if (definition.properties !== void 0) {
					schema.properties = Objects.deepClone(definition.properties);
				} else {
					schema.properties = Object.create(null);
				}
				schema.properties!.type = {
					type: 'string',
					enum: [definition.taskType]
				};
				schemas.push(schema);
			}
			this._schema = { oneOf: schemas };
		}
		return this._schema;
	}
開發者ID:,項目名稱:,代碼行數:26,代碼來源:

示例3: constructor

	constructor(options: string[], selected: number, styles: ISelectBoxStyles = deepClone(defaultStyles)) {
		super();

		this.selectElement = document.createElement('select');
		this.selectElement.className = 'select-box';

		this.setOptions(options, selected);
		this.toDispose = [];
		this._onDidSelect = new Emitter<ISelectData>();

		this.selectBackground = styles.selectBackground;
		this.selectForeground = styles.selectForeground;
		this.selectBorder = styles.selectBorder;

		this.toDispose.push(dom.addStandardDisposableListener(this.selectElement, 'change', (e) => {
			this.selectElement.title = e.target.value;
			this._onDidSelect.fire({
				index: e.target.selectedIndex,
				selected: e.target.value
			});
		}));
		this.toDispose.push(dom.addStandardDisposableListener(this.selectElement, 'keydown', (e) => {
			if (e.equals(KeyCode.Space) || e.equals(KeyCode.Enter)) {
				// Space is used to expand select box, do not propagate it (prevent action bar action run)
				e.stopPropagation();
			}
		}));
	}
開發者ID:SeanKilleen,項目名稱:vscode,代碼行數:28,代碼來源:selectBox.ts

示例4: constructor

	constructor(opts: ICheckboxOpts) {
		super();
		this._opts = objects.deepClone(opts);
		objects.mixin(this._opts, defaultOpts, false);
		this._checked = this._opts.isChecked;

		this.domNode = document.createElement('div');
		this.domNode.title = this._opts.title;
		this.domNode.className = 'monaco-custom-checkbox ' + this._opts.actionClassName + ' ' + (this._checked ? 'checked' : 'unchecked');
		this.domNode.tabIndex = 0;
		this.domNode.setAttribute('role', 'checkbox');
		this.domNode.setAttribute('aria-checked', String(this._checked));
		this.domNode.setAttribute('aria-label', this._opts.title);

		this.applyStyles();

		this.onclick(this.domNode, (ev) => {
			this.checked = !this._checked;
			this._opts.onChange(false);
			ev.preventDefault();
		});

		this.onkeydown(this.domNode, (keyboardEvent) => {
			if (keyboardEvent.keyCode === KeyCode.Space || keyboardEvent.keyCode === KeyCode.Enter) {
				this.checked = !this._checked;
				this._opts.onChange(true);
				keyboardEvent.preventDefault();
				return;
			}

			if (this._opts.onKeyDown) {
				this._opts.onKeyDown(keyboardEvent);
			}
		});
	}
開發者ID:jumpinjackie,項目名稱:sqlopsstudio,代碼行數:35,代碼來源:checkbox.ts

示例5: createTaskIdentifier

	export function createTaskIdentifier(external: TaskIdentifier, reporter: { error(message: string): void; }): KeyedTaskIdentifier | undefined {
		let definition = TaskDefinitionRegistry.get(external.type);
		if (definition === void 0) {
			// We have no task definition so we can't sanitize the literal. Take it as is
			let copy = Objects.deepClone(external);
			delete copy._key;
			return KeyedTaskIdentifier.create(copy);
		}

		let literal: { type: string;[name: string]: any } = Object.create(null);
		literal.type = definition.taskType;
		let required: Set<string> = new Set();
		definition.required.forEach(element => required.add(element));

		let properties = definition.properties;
		for (let property of Object.keys(properties)) {
			let value = external[property];
			if (value !== void 0 && value !== null) {
				literal[property] = value;
			} else if (required.has(property)) {
				let schema = properties[property];
				if (schema.default !== void 0) {
					literal[property] = Objects.deepClone(schema.default);
				} else {
					switch (schema.type) {
						case 'boolean':
							literal[property] = false;
							break;
						case 'number':
						case 'integer':
							literal[property] = 0;
							break;
						case 'string':
							literal[property] = '';
							break;
						default:
							reporter.error(nls.localize(
								'TaskDefinition.missingRequiredProperty',
								'Error: the task identifier \'{0}\' is missing the required property \'{1}\'. The task identifier will be ignored.', JSON.stringify(external, undefined, 0), property
							));
							return undefined;
					}
				}
			}
		}
		return KeyedTaskIdentifier.create(literal);
	}
開發者ID:developers23,項目名稱:vscode,代碼行數:47,代碼來源:tasks.ts

示例6: fork

function fork(id: string): cp.ChildProcess {
	const opts: any = {
		env: objects.mixin(objects.deepClone(process.env), {
			AMD_ENTRYPOINT: id,
			PIPE_LOGGING: 'true',
			VERBOSE_LOGGING: true
		})
	};

	return cp.fork(URI.parse(require.toUrl('bootstrap')).fsPath, ['--type=processTests'], opts);
}
開發者ID:burhandodhy,項目名稱:azuredatastudio,代碼行數:11,代碼來源:processes.test.ts

示例7: fork

function fork(id: string): cp.ChildProcess {
	const opts: any = {
		env: objects.mixin(objects.deepClone(process.env), {
			AMD_ENTRYPOINT: id,
			PIPE_LOGGING: 'true',
			VERBOSE_LOGGING: true
		})
	};

	return cp.fork(getPathFromAmdModule(require, 'bootstrap-fork'), ['--type=processTests'], opts);
}
開發者ID:DonJayamanne,項目名稱:vscode,代碼行數:11,代碼來源:processes.test.ts

示例8: parseCommandOptions

	private parseCommandOptions(json: Config.CommandOptions): CommandOptions {
		let result: CommandOptions = {};
		if (!json) {
			return result;
		}
		if (this.is(json.cwd, Types.isString, ValidationState.Warning, NLS.localize('ExecutableParser.invalidCWD', 'Warning: options.cwd must be of type string. Ignoring value {0}.', json.cwd))) {
			result.cwd = json.cwd;
		}
		if (!Types.isUndefined(json.env)) {
			result.env = Objects.deepClone(json.env);
		}
		return result;
	}
開發者ID:SeanKilleen,項目名稱:vscode,代碼行數:13,代碼來源:processes.ts

示例9: from

	export function from(value: TaskDefinition, extensionId: string, messageCollector: ExtensionMessageCollector): Tasks.TaskDefinition | undefined {
		if (!value) {
			return undefined;
		}
		let taskType = Types.isString(value.type) ? value.type : undefined;
		if (!taskType || taskType.length === 0) {
			messageCollector.error(nls.localize('TaskTypeConfiguration.noType', 'The task type configuration is missing the required \'taskType\' property'));
			return undefined;
		}
		let required: string[] = [];
		if (Array.isArray(value.required)) {
			for (let element of value.required) {
				if (Types.isString(element)) {
					required.push(element);
				}
			}
		}
		return { extensionId, taskType, required: required, properties: value.properties ? Objects.deepClone(value.properties) : {} };
	}
開發者ID:,項目名稱:,代碼行數:19,代碼來源:

示例10:

				nls.localize('JsonSchema.tasks.presentation.reveal.silent', 'Only reveals the terminal if no problem matcher is associated with the task and an errors occurs executing it.'),
				nls.localize('JsonSchema.tasks.presentation.reveal.never', 'Never reveals the terminal when this task is executed.'),
			],
			default: 'always',
			description: nls.localize('JsonSchema.tasks.presentation.reveals', 'Controls whether the panel running the task is revealed or not. Default is \"always\".')
		},
		panel: {
			type: 'string',
			enum: ['shared', 'dedicated', 'new'],
			default: 'shared',
			description: nls.localize('JsonSchema.tasks.presentation.instance', 'Controls if the panel is shared between tasks, dedicated to this task or a new one is created on every run.')
		}
	}
};

const terminal: IJSONSchema = Objects.deepClone(presentation);
terminal.deprecationMessage = nls.localize('JsonSchema.tasks.terminal', 'The terminal property is deprecated. Use presentation instead');

const group: IJSONSchema = {
	oneOf: [
		{
			type: 'string',
		},
		{
			type: 'object',
			properties: {
				kind: {
					type: 'string',
					default: 'none',
					description: nls.localize('JsonSchema.tasks.group.kind', 'The task\'s execution group.')
				},
開發者ID:jinlongchen2018,項目名稱:vscode,代碼行數:31,代碼來源:jsonSchema_v2.ts


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