当前位置: 首页>>代码示例>>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;未经允许,请勿转载。