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