本文整理汇总了TypeScript中yn.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: yn
argv => {
process.IS_PRODUCTION = argv.production || yn(process.env.BP_PRODUCTION)
let defaultVerbosity = process.IS_PRODUCTION ? 0 : 2
if (!isNaN(Number(process.env.VERBOSITY_LEVEL))) {
defaultVerbosity = Number(process.env.VERBOSITY_LEVEL)
}
process.VERBOSITY_LEVEL = argv.verbose ? Number(argv.verbose) : defaultVerbosity
process.IS_LICENSED = true
process.ASSERT_LICENSED = () => {}
process.BOTPRESS_VERSION = metadataContent.version
const isProBuild = fs.existsSync(path.resolve(process.PROJECT_LOCATION, 'pro')) || process.pkg
const configPath = path.join(process.PROJECT_LOCATION, '/data/global/botpress.config.json')
if (isProBuild) {
process.CLUSTER_ENABLED = yn(process.env.CLUSTER_ENABLED)
if (process.env.PRO_ENABLED === undefined) {
if (fs.existsSync(configPath)) {
const config = require(configPath)
process.IS_PRO_ENABLED = config.pro && config.pro.enabled
}
} else {
process.IS_PRO_ENABLED = yn(process.env.PRO_ENABLED)
}
}
getos.default().then(distro => {
process.distro = distro
require('./bootstrap')
})
}
示例2: require
try {
const argv = require('yargs')
.option('verbose', {
alias: 'v',
description: 'verbosity level'
})
.option('production', {
alias: 'p',
default: false,
description: 'run in production mode'
})
.boolean('production')
.count('verbose')
.help().argv
process.IS_PRODUCTION = argv.production || yn(process.env.BP_PRODUCTION)
let defaultVerbosity = process.IS_PRODUCTION ? 0 : 2
if (!isNaN(Number(process.env.VERBOSITY_LEVEL))) {
defaultVerbosity = Number(process.env.VERBOSITY_LEVEL)
}
process.VERBOSITY_LEVEL = argv.verbose ? Number(argv.verbose) : defaultVerbosity
process.IS_LICENSED = true
process.ASSERT_LICENSED = () => {}
process.BOTPRESS_VERSION = metadataContent.version
process.BOTPRESS_EDITION = metadataContent.edition
require('./bootstrap')
} catch (err) {
global.printErrorDefault(err)
示例3: yn
export const extractMetadata = (code: string) => {
const match = code.match(JSDocCommentRegex)
const metadata: ActionMetadata = {
title: '',
category: '',
description: '',
author: '',
hidden: false,
params: []
}
if (!match) {
return metadata
}
const extracted = doctrine.parse(match[0], {
recoverable: true,
sloppy: true,
unwrap: true,
strict: false,
preserveWhitespace: false
})
metadata.description = extracted.description
const author = _.find(extracted.tags, { title: 'author' })
if (author) {
metadata.author = (author as any).description || ''
}
const category = _.find(extracted.tags, { title: 'category' })
if (category) {
metadata.category = (category as any).description || ''
}
const title = _.find(extracted.tags, { title: 'title' })
if (title) {
metadata.title = (title as any).description || ''
}
const hidden = _.find(extracted.tags, { title: 'hidden' })
if (hidden) {
metadata.hidden = yn((hidden as any).description)
}
metadata.params = _.filter(extracted.tags, { title: 'param' }).map(tag => {
const type: string = _.get(tag, 'type.name', '')
const required = _.get(tag, 'type.type') !== doctrine.type.Syntax.OptionalType
const def = _.get(tag, 'default', '')
const name = _.get(tag, 'name', '')
return {
description: (tag as any).description || '',
type,
default: def,
required,
name
}
})
return metadata
}
示例4: importQuestions
router.post('/import/csv', upload.single('csv'), async (req, res) => {
const storage = botScopedStorage.get(req.params.botId)
const config = await bp.config.getModuleConfigForBot('qna', req.params.botId)
const uploadStatusId = nanoid()
res.end(uploadStatusId)
updateUploadStatus(uploadStatusId, 'Deleting existing questions')
if (yn(req.body.isReplace)) {
const questions = await storage.fetchAllQuestions()
const statusCb = processedCount =>
updateUploadStatus(uploadStatusId, `Deleted ${processedCount}/${questions.length} questions`)
await storage.delete(questions.map(({ id }) => id), statusCb)
}
try {
const questions = iconv.decode(req.file.buffer, config.exportCsvEncoding)
const params = {
storage,
config,
format: 'csv',
statusCallback: updateUploadStatus,
uploadStatusId
}
await importQuestions(questions, params)
updateUploadStatus(uploadStatusId, 'Completed')
} catch (e) {
bp.logger.error('Upload error :', e)
updateUploadStatus(uploadStatusId, `Error: ${e.message}`)
}
})