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


TypeScript undefined.default函數代碼示例

本文整理匯總了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);
}
開發者ID:BrowserSync,項目名稱:browser-sync,代碼行數:12,代碼來源:bin.ts

示例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);
                }
            }
開發者ID:eez-open,項目名稱:studio,代碼行數:30,代碼來源:service.ts

示例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();
  });
開發者ID:AriFreyr,項目名稱:EveApp,代碼行數:15,代碼來源:tasks_tools.ts

示例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;
  }
開發者ID:Volune,項目名稱:jest,代碼行數:34,代碼來源:SearchSource.ts

示例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);
            }
        }
    }
開發者ID:deepeshdesigns,項目名稱:typedoc,代碼行數:42,代碼來源:plugins.ts

示例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;
	}
});
開發者ID:sinnerschrader,項目名稱:patternplate-vscode,代碼行數:34,代碼來源:patternplate-process.ts

示例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);
        }
    }

});
開發者ID:streamich,項目名稱:portable,代碼行數:32,代碼來源:cli.ts

示例8: request

 doRequest(options: RequestOptions) {
   this.logger.info(`[ ${options.method} ] : ` + options.uri);
   //request.debug = true;
   
   options.headers = this.headers;
   return request(options);
 }
開發者ID:rey-symphony,項目名稱:node-symphony,代碼行數:7,代碼來源:APIBase.ts

示例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)
}
開發者ID:aranja,項目名稱:tux,代碼行數:30,代碼來源:new.ts

示例10: task

    gulp.task(taskname, function (cb: any) {
        let task = require('./' + TASK);
        if (task.length > 0) {
            return task(cb);
        }

    });
開發者ID:garyttierney,項目名稱:blog,代碼行數:7,代碼來源:gulpfile.ts


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