• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript objects.clone函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript objects.cloneAndChange函数代码示例发布时间:2022-05-25
下一篇:
TypeScript objects.assign函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap