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


TypeScript slug類代碼示例

本文整理匯總了TypeScript中slug的典型用法代碼示例。如果您正苦於以下問題:TypeScript slug類的具體用法?TypeScript slug怎麽用?TypeScript slug使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了slug類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: team

  robot.respondAsync(/tell me about team (.*)/i, async (response) => {
    const teamId = slug(response.match[1], { lower: true })

    const res = await robot.client.getTeam(teamId)
    if (res.statusCode === 404) {
      return response.reply(`Sorry, I can't find that team.`)
    }
    if (!res.ok) {
      return response.reply('Sorry, there was a problem when I tried to look up that team :frowning:')
    }

    if (res.team.members.length === 0) {
      return response.reply(`"${res.team.name}" is an empty team.`)
    }

    const user = robot.adapter.client.rtm.dataStore.getUserByName(response.message.user.name)

    if (res.team.members.length === 1 && res.team.members[0].id === user.id) {
      const motto = res.team.motto === null ? `and you have not yet set your motto!` : `and your motto is: ${res.team.motto}`
      return response.reply(`You are the only member of "${res.team.name}" ${motto}`)
    }

    const memberList = res.team.members.map((member) => member.name)
    const noun = res.team.members.length === 1 ? 'member' : 'members'
    const motto = res.team.motto === null ? `They don't yet have a motto!` : `They say: ${res.team.motto}`

    response.reply(`"${res.team.name}" has ${res.team.members.length} ${noun}: ${memberList.join(', ')}\r\n${motto}`)
  })
開發者ID:Codesleuth,項目名稱:hubot-hackbot,代碼行數:28,代碼來源:tell_me_about_team.script.ts

示例2: setupCommands

export function setupCommands(server: Server, commands: CommandDefinition[]) {
    // Generate and register routes for commands
    for (let command of commands) {
        server.route({
            method: command.method || "GET",
            path: urljoin("/commands", command.path || slug(command.name)),
            config: {
                auth: command.auth
            },
            handler: buildCommandHandler({ command: command.command, options: command.options })
        });
    }
}
開發者ID:msurdi,項目名稱:smu,代碼行數:13,代碼來源:commands.ts

示例3: slugify

export function slugify(name: string): string {
  return slug(name, { lower: true })
}
開發者ID:TechNottingham,項目名稱:Hack24-API,代碼行數:3,代碼來源:utils.ts

示例4: function

 return function(text, render) {
     return slug(render(text)).toLowerCase();
 };
開發者ID:2fd,項目名稱:graphdoc,代碼行數:3,代碼來源:template.ts

示例5: createTenant

 createTenant(tenant: Tenant): Observable<any> {
   tenant['slug'] = slug(tenant.name, { lower: true });
   return this.apiService.post('/tenants', tenant);
 }
開發者ID:CrisLi,項目名稱:reits-console,代碼行數:4,代碼來源:tenant.service.ts

示例6: function

 fn: function(txt, opts) {
   return slug(txt, opts);
 }
開發者ID:tbtimes,項目名稱:lede,代碼行數:3,代碼來源:NunjucksCompiler.ts


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