当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Emitter.on方法代码示例

本文整理汇总了TypeScript中typings-core.Emitter.on方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Emitter.on方法的具体用法?TypeScript Emitter.on怎么用?TypeScript Emitter.on使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在typings-core.Emitter的用法示例。


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

示例1: EventEmitter

})

const cwd = process.cwd()
const emitter: Emitter = new EventEmitter()
const isDev = IS_PRODUCTION ? argv.dev : !argv.production
const args: Args = extend({ cwd, emitter }, argv, { dev: isDev, production: !isDev })

// Notify the user of updates.
updateNotifier({ pkg }).notify()

// Execute with normalizations applied.
exec(args)

// Log warnings on enoent events.
emitter.on('enoent', function ({ path }) {
  logWarning(`Path "${path}" is missing`, 'enoent')
})

// Log warning when typings come packaged.
emitter.on('hastypings', function ({ name, typings }) {
  logWarning(
    `Typings for "${name}" already exist in "${relative(cwd, typings)}". You should ` +
    `let TypeScript resolve the packaged typings and uninstall the copy installed by Typings`,
    'hastypings'
  )
})

// Emit postmessage events.
emitter.on('postmessage', function ({ message, name }) {
  logInfo(`${name}: ${message}`, 'postmessage')
})
开发者ID:CedarLogic,项目名称:typings,代码行数:31,代码来源:bin.ts

示例2: EventEmitter

})

const cwd = process.cwd()
const emitter: Emitter = new EventEmitter()
const isDev = IS_PRODUCTION ? argv.dev : !argv.production
const args: Args = extend({ cwd, emitter }, argv, { dev: isDev, production: !isDev })

// Notify the user of updates.
updateNotifier({ pkg }).notify()

// Execute with normalizations applied.
exec(args)

// Log warnings on enoent events.
emitter.on('enoent', function ({ path }) {
  logWarning(`Path "${path}" is missing`, 'ENOENT')
})

// Log warning when typings come packaged.
emitter.on('hastypings', function ({ name, typings }) {
  logWarning(
    `Typings for "${name}" already exist in "${relative(cwd, typings)}". You should ` +
    `let TypeScript resolve the packaged typings and uninstall the copy installed by Typings`,
    'has typings'
  )
})

// Emit postmessage events.
emitter.on('postmessage', function ({ message, name }) {
  logInfo(message, `${name} postmessage`)
})
开发者ID:chriseyhorn,项目名称:typings,代码行数:31,代码来源:bin.ts

示例3: resolve

  }
})

const cwd = argv.cwd ? resolve(argv.cwd) : process.cwd()
const emitter: Emitter = new EventEmitter()
const args: Args = extend(argv, { emitter, cwd })

// Notify the user of updates.
updateNotifier({ pkg }).notify()

// Execute with normalizations applied.
exec(args)

// Log warnings on enoent events.
emitter.on('enoent', function ({ path }) {
  logWarning(`Path "${path}" is missing`, 'enoent')
})

// Log warning when typings come packaged.
emitter.on('hastypings', function ({ name, typings }) {
  logWarning(
    `Typings for "${name}" already exist in "${relative(cwd, typings)}". You should ` +
    `let TypeScript resolve the packaged typings and uninstall the copy installed by Typings`,
    'hastypings'
  )
})

// Emit postmessage events.
emitter.on('postmessage', function ({ message, name }) {
  logInfo(`${name}: ${message}`, 'postmessage')
})
开发者ID:AndreiShostik,项目名称:typings,代码行数:31,代码来源:bin.ts

示例4: EventEmitter

})

const cwd = process.cwd()
const emitter: Emitter = new EventEmitter()
const isDev = IS_PRODUCTION ? argv.dev : !argv.production
const args: Args = extend({ cwd, emitter }, argv, { dev: isDev, production: !isDev })

// Notify the user of updates.
updateNotifier({ pkg }).notify()

// Execute with normalizations applied.
exec(args)

// Log warnings on enoent events.
emitter.on('enoent', function ({ path }) {
  logWarning(`Path "${path}" is missing`, 'ENOENT')
})

/**
 * Handle the CLI commands.
 */
function exec (options: Args): any {
  if (options._.length) {
    const command = ALIASES[options._[0]]
    const args = options._.slice(1)

    if (command != null) {
      if (options.help) {
        return handle(command.help(args, options), options)
      }
开发者ID:SethDavenport,项目名称:typings,代码行数:30,代码来源:bin.ts


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