本文整理汇总了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}`)
})
示例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 })
});
}
}
示例3: slugify
export function slugify(name: string): string {
return slug(name, { lower: true })
}
示例4: function
return function(text, render) {
return slug(render(text)).toLowerCase();
};
示例5: createTenant
createTenant(tenant: Tenant): Observable<any> {
tenant['slug'] = slug(tenant.name, { lower: true });
return this.apiService.post('/tenants', tenant);
}
示例6: function
fn: function(txt, opts) {
return slug(txt, opts);
}