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


TypeScript yn.default函數代碼示例

本文整理匯總了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')
        })
      }
開發者ID:alexsandrocruz,項目名稱:botpress,代碼行數:34,代碼來源:index.ts

示例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)
開發者ID:seffalabdelaziz,項目名稱:botpress,代碼行數:31,代碼來源:index.ts

示例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
}
開發者ID:alexsandrocruz,項目名稱:botpress,代碼行數:62,代碼來源:metadata.ts

示例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}`)
    }
  })
開發者ID:seffalabdelaziz,項目名稱:botpress,代碼行數:33,代碼來源:api.ts


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