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


TypeScript objects.clone函數代碼示例

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


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

示例1: test

	test('StorageSevice cleans up when workspace changes', () => {
		let storageImpl = new InMemoryLocalStorage();
		let context = new TestContextService();
		let s = new StorageService(storageImpl, null, context);

		s.store('key1', 'foobar');
		s.store('key2', 'something');
		s.store('wkey1', 'foo', StorageScope.WORKSPACE);
		s.store('wkey2', 'foo2', StorageScope.WORKSPACE);

		s = new StorageService(storageImpl, null, context);

		assert.strictEqual(s.get('key1', StorageScope.GLOBAL), 'foobar');
		assert.strictEqual(s.get('key1', StorageScope.WORKSPACE, null), null);

		assert.strictEqual(s.get('key2', StorageScope.GLOBAL), 'something');
		assert.strictEqual(s.get('wkey1', StorageScope.WORKSPACE), 'foo');
		assert.strictEqual(s.get('wkey2', StorageScope.WORKSPACE), 'foo2');

		let ws: any = clone(TestWorkspace);
		ws.uid = new Date().getTime() + 100;
		context = new TestContextService(ws);
		s = new StorageService(storageImpl, null, context);

		assert.strictEqual(s.get('key1', StorageScope.GLOBAL), 'foobar');
		assert.strictEqual(s.get('key1', StorageScope.WORKSPACE, null), null);

		assert.strictEqual(s.get('key2', StorageScope.GLOBAL), 'something');
		assert(!s.get('wkey1', StorageScope.WORKSPACE));
		assert(!s.get('wkey2', StorageScope.WORKSPACE));
	});
開發者ID:sandy081,項目名稱:vscode,代碼行數:31,代碼來源:storageService.test.ts

示例2: test

	test("Storage cleans up when workspace changes", () => {
		let storageImpl = new InMemoryLocalStorage();
		let context = new TestContextService();
		let s = new Storage(context, storageImpl);

		s.store("key1", "foobar");
		s.store("key2", "something");
		s.store("wkey1", "foo", StorageScope.WORKSPACE);
		s.store("wkey2", "foo2", StorageScope.WORKSPACE);

		s = new Storage(context, storageImpl);

		assert.strictEqual(s.get("key1", StorageScope.GLOBAL), "foobar");
		assert.strictEqual(s.get("key1", StorageScope.WORKSPACE, null), null);

		assert.strictEqual(s.get("key2", StorageScope.GLOBAL), "something");
		assert.strictEqual(s.get("wkey1", StorageScope.WORKSPACE), "foo");
		assert.strictEqual(s.get("wkey2", StorageScope.WORKSPACE), "foo2");

		let ws: any = clone(TestWorkspace);
		ws.uid = new Date().getTime() + 100;
		context = new TestContextService(ws);
		s = new Storage(context, storageImpl);

		assert.strictEqual(s.get("key1", StorageScope.GLOBAL), "foobar");
		assert.strictEqual(s.get("key1", StorageScope.WORKSPACE, null), null);

		assert.strictEqual(s.get("key2", StorageScope.GLOBAL), "something");
		assert(!s.get("wkey1", StorageScope.WORKSPACE));
		assert(!s.get("wkey2", StorageScope.WORKSPACE));
	});
開發者ID:gaoxiaojun,項目名稱:vscode,代碼行數:31,代碼來源:storage.test.ts

示例3: getConfiguration

	public getConfiguration(section?: string): WorkspaceConfiguration {
		if (!this._hasConfig) {
			throw illegalState('missing config');
		}

		const config = section
			? ExtHostConfiguration._lookUp(section, this._config)
			: this._config;

		let result: any;
		if (typeof config !== 'object') {
			// this catches missing config and accessing values
			result = {};
		} else {
			result = clone(config);
		}

		result.has = function(key: string): boolean {
			return typeof ExtHostConfiguration._lookUp(key, config) !== 'undefined';
		};
		result.get = function <T>(key: string, defaultValue?: T): T {
			let result = ExtHostConfiguration._lookUp(key, config);
			if (typeof result === 'undefined') {
				result = defaultValue;
			}
			return result;
		};
		return result;
	}
開發者ID:AjuanM,項目名稱:vscode,代碼行數:29,代碼來源:extHostConfiguration.ts

示例4: constructor

	constructor(opts: ICheckboxOpts) {
		super();
		this._opts = objects.clone(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 = this._className();
		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:Chan-PH,項目名稱:vscode,代碼行數:35,代碼來源:checkbox.ts

示例5: constructor

	constructor(options: string[], selected: number, styles: ISelectBoxStyles = clone(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:Chan-PH,項目名稱:vscode,代碼行數:28,代碼來源:selectBox.ts

示例6: resolveExecutable

export function resolveExecutable(executable: Executable, variables: ISystemVariables): Executable {
	let result = Objects.clone(executable);
	result.command = variables.resolve(result.command);
	result.args = variables.resolve(result.args);
	if (result.options) {
		result.options = resolveCommandOptions(result.options, variables);
	}
	return result;
}
開發者ID:microfins,項目名稱:vscode,代碼行數:9,代碼來源:processes.ts

示例7: resolveCommandOptions

export function resolveCommandOptions(options: CommandOptions, variables: ISystemVariables): CommandOptions {
	let result = Objects.clone(options);
	if (result.cwd) {
		result.cwd = variables.resolve(result.cwd);
	}
	if (result.env) {
		result.env = variables.resolve(result.env);
	}
	return result;
}
開發者ID:microfins,項目名稱:vscode,代碼行數:10,代碼來源:processes.ts

示例8: fork

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

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

示例9: 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.clone(json.env);
		}
		return result;
	}
開發者ID:StateFarmIns,項目名稱:vscode,代碼行數:13,代碼來源:processes.ts

示例10: constructor

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

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

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

		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(e.target.value);
		}));
	}
開發者ID:FabianLauer,項目名稱:vscode,代碼行數:19,代碼來源:selectBox.ts


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