本文整理汇总了TypeScript中typings-core.Emitter类的典型用法代码示例。如果您正苦于以下问题:TypeScript Emitter类的具体用法?TypeScript Emitter怎么用?TypeScript Emitter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Emitter类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: EventEmitter
boolean: ['version', 'save', 'saveDev', 'savePeer', 'ambient', 'verbose', 'dev', 'production'],
string: ['cwd', 'out', 'name'],
alias: {
ambient: ['A'],
version: ['v'],
save: ['S'],
saveDev: ['save-dev', 'D'],
savePeer: ['savePeer', 'P'],
verbose: ['V'],
out: ['o'],
help: ['h']
}
})
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.
示例2: resolve
global: ['G'],
version: ['v'],
save: ['S'],
saveDev: ['save-dev', 'D'],
savePeer: ['savePeer', 'P'],
verbose: ['V'],
out: ['o'],
help: ['h']
},
default: {
production: process.env.NODE_ENV === 'production'
}
})
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 }) {
示例3: EventEmitter
boolean: ['version', 'save', 'saveDev', 'savePeer', 'ambient', 'verbose', 'dev', 'production'],
string: ['cwd', 'out', 'name'],
alias: {
ambient: ['A'],
version: ['v'],
save: ['S'],
saveDev: ['save-dev', 'D'],
savePeer: ['savePeer', 'P'],
verbose: ['V'],
out: ['o'],
help: ['h']
}
})
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')
})
/**