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

TypeScript lang.mixin函数代码示例

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

本文整理汇总了TypeScript中@dojo/core/lang.mixin函数的典型用法代码示例。如果您正苦于以下问题:TypeScript mixin函数的具体用法?TypeScript mixin怎么用?TypeScript mixin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了mixin函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: getConfig

export function getConfig(fileOrArgv?: string | string[], argv?: string[]) {
	let args: { [key: string]: any } = {};
	let file = typeof fileOrArgv === 'string' ? fileOrArgv : undefined;
	argv = Array.isArray(fileOrArgv) ? fileOrArgv : argv;
	const userArgs = (argv || process.argv).slice(2);

	if (process.env['INTERN_ARGS']) {
		mixin(args, parseArgs(parse(process.env['INTERN_ARGS'] || '')));
	}

	if (userArgs.length > 0) {
		mixin(args, parseArgs(userArgs));
	}

	if (file) {
		args.config = file;
	}

	let load: Task<{ [key: string]: any }>;

	if (args.config) {
		// If a config parameter was provided, load it and mix in any other
		// command line args.
		const { configFile, childConfig } = splitConfigPath(args.config, sep);
		file = resolve(configFile || 'intern.json');
		load = loadConfig(file, loadText, args, childConfig);
	} else {
		// If no config parameter was provided, try 'intern.json', or just
		// resolve to the original args
		file = resolve('intern.json');
		load = loadConfig(file, loadText, args, undefined).catch(
			(error: NodeJS.ErrnoException) => {
				if (error.code === 'ENOENT') {
					file = undefined;
					return args;
				}
				throw error;
			}
		);
	}

	return load
		.then(config => {
			// If a basePath wasn't set in the config or via a query arg, and we
			// have a config file path, use that.
			if (file) {
				config.basePath = getBasePath(
					file,
					config.basePath,
					isAbsolute,
					sep
				);
			}
			return config;
		})
		.then(config => ({ config, file }));
}
开发者ID:devpaul,项目名称:intern,代码行数:57,代码来源:util.ts


示例2: mockPath

export function mockPath(
	properties: { [P in keyof typeof path]?: typeof path[P] } = {}
) {
	return createMock<typeof path>(
		mixin(
			{
				resolve(path: string) {
					// Normalize fake directory names by adding a trailing '/'
					if (!/\.\w+$/.test(path) && path[path.length - 1] !== '/') {
						return path + '/';
					}
					return path;
				},

				join(...args: any[]) {
					return path.join(...args);
				},

				basename(base: string, ...args: any[]) {
					return path.basename(base, ...args);
				},

				normalize(base: string, ...args: any[]) {
					return path.normalize(base, ...args);
				}
			},
			properties
		)
	);
}
开发者ID:devpaul,项目名称:intern,代码行数:30,代码来源:nodeMocks.ts


示例3: mixin

						['node', 'browser'].forEach(key => {
							if (child[key]) {
								if (config[key]) {
									mixin(config[key], child[key]);
								} else {
									config[key] = child[key];
								}
							}
						});
开发者ID:jason0x43,项目名称:intern,代码行数:9,代码来源:util.ts


示例4: constructor

	constructor(options: ServerOptions) {
		mixin(
			this,
			{
				basePath: '.',
				runInSync: false
			},
			options
		);
	}
开发者ID:jason0x43,项目名称:intern,代码行数:10,代码来源:Server.ts


示例5: constructor

	constructor(options?: TunnelOptions) {
		super(
			mixin(
				{
					auth: ''
				},
				options || {}
			)
		);
	}
开发者ID:devpaul,项目名称:digdug,代码行数:10,代码来源:NullTunnel.ts


示例6: createTest

export function createTest(properties?: { [P in keyof Test]?: Test[P] }) {
	let test = new Test({
		name: 'test',
		test() {}
	});
	if (properties) {
		test = Object.create(test);
		mixin(test, properties || {});
	}
	return test;
}
开发者ID:jason0x43,项目名称:intern,代码行数:11,代码来源:factories.ts


示例7: createSuite

export function createSuite(properties?: { [P in keyof Suite]?: Suite[P] }) {
	let suite = new Suite({
		name: 'suite',
		executor: mockExecutor()
	});
	if (properties) {
		suite = Object.create(suite);
		mixin(suite, properties || {});
	}
	return suite;
}
开发者ID:jason0x43,项目名称:intern,代码行数:11,代码来源:factories.ts


示例8: mockFs

export function mockFs(
	fileData: FileData = Object.create(null),
	properties: MockFsProperties = {}
) {
	function missingFile(path: string) {
		return assign(
			new Error(
				`Error: ENOENT: no such file or directory stat '${path}' errno -2`
			),
			{
				code: 'ENOENT',
				errno: -2,
				syscall: 'stat',
				path
			}
		);
	}

	const mock = createMock<MockFs>(
		mixin(
			{
				__fileData: fileData,

				stat(path: string, callback: StatCallback) {
					const entry = mock.__fileData[path];
					if (!entry) {
						callback(
							missingFile(path),
							new MockStats(path, undefined)
						);
					} else {
						callback(undefined, new MockStats(path, entry.type));
					}
				},

				readFile(
					path: string,
					_encoding: string,
					callback: FsCallback
				) {
					const entry = mock.__fileData[path];
					if (!entry) {
						callback(missingFile(path), undefined);
					} else {
						callback(undefined, entry.data);
					}
				}
			},
			properties
		)
	);
	return mock;
}
开发者ID:devpaul,项目名称:intern,代码行数:53,代码来源:nodeMocks.ts


示例9: getConfig

export function getConfig(configFile?: string) {
	let args: { [key: string]: any } = {};

	if (process.env['INTERN_ARGS']) {
		mixin(args, parseArgs(parse(process.env['INTERN_ARGS'])));
	}

	if (process.argv.length > 2) {
		mixin(args, parseArgs(process.argv.slice(2)));
	}

	if (configFile) {
		args.config = configFile;
	}

	if (args.config) {
		// If a config parameter was provided, load it and mix in any other
		// command line args.
		const { configFile, childConfig } = splitConfigPath(args.config, sep);
		return loadConfig(
			configFile || 'intern.json',
			loadText,
			args,
			childConfig
		);
	} else {
		// If no config parameter was provided, try 'intern.json', or just
		// resolve to the original args
		return loadConfig(
			'intern.json',
			loadText,
			args
		).catch((error: NodeJS.ErrnoException) => {
			if (error.code === 'ENOENT') {
				return args;
			}
			throw error;
		});
	}
}
开发者ID:jason0x43,项目名称:intern,代码行数:40,代码来源:util.ts



注:本文中的@dojo/core/lang.mixin函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript xhr.default函数代码示例发布时间:2022-05-28
下一篇:
TypeScript lang.deepMixin函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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