本文整理匯總了TypeScript中undefined.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了default函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: handleCli
/**
* @param {{cli: object, [whitelist]: array, [cb]: function}} opts
* @returns {*}
*/
function handleCli(opts) {
opts.cb = opts.cb || utils.defaultCallback;
const m = require(`./cli/command.${opts.cli.input[0]}`);
if (m.default) {
return m.default(opts);
}
return m(opts);
}
示例2: send
(event: Electron.Event, task: ITask) => {
function send(taskResult: ITaskResult) {
// send result back to calling process
EEZStudio.electron.ipcRenderer.sendTo(
task.windowId,
TASK_DONE_CHANNEL + task.taskId,
taskResult
);
}
function sendResult(result: any) {
send({ result });
}
function sendError(error: any) {
send({ error });
}
try {
const serviceImplementation: (
inputParams: any
) => Promise<any> = require(task.serviceName).default;
serviceImplementation(task.inputParams)
.then(sendResult)
.catch(sendError);
} catch (error) {
sendError(error);
}
}
示例3: task
gulp.task(taskname, (done: any) => {
const task = require(TASK);
if (task.length > 0) {
return task(done);
}
const taskReturnedValue = task();
if (isstream(taskReturnedValue)) {
return taskReturnedValue;
}
// TODO: add promise handling if needed at some point.
done();
});
示例4: getTestPaths
async getTestPaths(
globalConfig: Config.GlobalConfig,
changedFiles: ChangedFiles | undefined,
): Promise<SearchResult> {
const searchResult = this._getTestPaths(globalConfig, changedFiles);
const filterPath = globalConfig.filter;
if (filterPath && !globalConfig.skipFilter) {
const tests = searchResult.tests;
const filter = require(filterPath);
const filterResult: {filtered: Array<FilterResult>} = await filter(
tests.map(test => test.path),
);
if (!Array.isArray(filterResult.filtered)) {
throw new Error(
`Filter ${filterPath} did not return a valid test list`,
);
}
const filteredSet = new Set(
filterResult.filtered.map(result => result.test),
);
return {
...searchResult,
tests: tests.filter(test => filteredSet.has(test.path)),
};
}
return searchResult;
}
示例5: load
/**
* Load the given list of npm plugins.
*
* @param plugins A list of npm modules that should be loaded as plugins. When not specified
* this function will invoke [[discoverNpmPlugins]] to find a list of all installed plugins.
* @returns TRUE on success, otherwise FALSE.
*/
load(): boolean {
const logger = this.application.logger;
const plugins = this.plugins || this.discoverNpmPlugins();
let i: number, c: number = plugins.length;
for (i = 0; i < c; i++) {
const plugin = plugins[i];
if (typeof plugin !== 'string') {
logger.error('Unknown plugin %s', plugin);
return false;
} else if (plugin.toLowerCase() === 'none') {
return true;
}
}
for (i = 0; i < c; i++) {
const plugin = plugins[i];
try {
const instance = require(plugin);
const initFunction = typeof instance.load === 'function'
? instance.load
: instance // support legacy plugins
;
if (typeof initFunction === 'function') {
instance(this);
logger.write('Loaded plugin %s', plugin);
} else {
logger.error('Invalid structure in plugin %s, no function found.', plugin);
}
} catch (error) {
logger.error('The plugin %s could not be loaded.', plugin);
logger.writeln(error.stack);
}
}
}
示例6: require
process.on('message', (message: RPC.Message) => {
switch (message.type) {
case 'start':
cwd = (message as RPC.Start).cwd;
console.log(`Starting patternplate in ${cwd}`);
process.chdir(cwd);
const patternplatePath = path.join(cwd, 'node_modules', 'patternplate') || 'patternplate';
const patternplate = require(patternplatePath);
patternplate({
mode: 'server'
}).then(app => {
// set and freeze logger
app.log.deploy(new Logger());
app.log.deploy = function() {}
return app.start()
.then(() => app);
}).then(app => {
const port = app.configuration.server.port;
console.log(`Started patternplate on port '${port}'`)
process.send({
type: 'started',
port
} as RPC.Started);
}).catch(error => {
console.log(JSON.stringify(error));
process.send({
type: 'error',
error: error.message
} as RPC.Error)
});
break;
}
});
示例7: require
cli.main(function(args, options) {
try {
if(cli.command) {
if(commands.indexOf(cli.command) < 0) throw Error('Invalid command: ' + cli.command);
// First try to run the `portable-js` package that is installed in folder where manifest file is located,
// if not found, run the command from the global package.
var manifest_dir = '';
if(options.file) {
manifest_dir = path.dirname(options.file);
} else {
manifest_dir = process.cwd();
}
var command_dir = manifest_dir + '/node_modules/portable-js/src/command';
if(!fs.existsSync(command_dir)) command_dir = __dirname + '/command';
if(options.verbose) log.level = 'verbose';
if(options.debug) log.level = 'silly';
var cmd = require(command_dir + '/' + cli.command + '.js');
cmd(args, options);
} else {
log.error('Command not found: ' + cli.command);
}
} catch(e) {
log.error(e);
if(options.debug) {
console.log(e.stack || e);
}
}
});
示例8: request
doRequest(options: RequestOptions) {
this.logger.info(`[ ${options.method} ] : ` + options.uri);
//request.debug = true;
options.headers = this.headers;
return request(options);
}
示例9: run
async function run(app: string, version: string, verbose: boolean) {
const allDependencies = [appendVersion('tux-scripts', version)]
console.log('Installing packages. This might take a couple minutes.')
const useYarn = shouldUseYarn()
const isOnline = await checkIfOnline(useYarn)
console.log(`Installing ${chalk.cyan('tux-scripts')}...`)
console.log()
await install(useYarn, allDependencies, verbose, isOnline)
checkNodeVersion()
// Since react-scripts has been installed with --save
// we need to move it into devDependencies and rewrite package.json
// also ensure react dependencies have caret version range
await fixDependencies()
const scriptsPath = path.resolve(
process.cwd(),
'node_modules',
'tux-scripts',
'new'
)
const init = require(scriptsPath)
await init(root, app, verbose)
}
示例10: task
gulp.task(taskname, function (cb: any) {
let task = require('./' + TASK);
if (task.length > 0) {
return task(cb);
}
});