1 Star 0 Fork 34

liming0101/outline.js

forked from Yaohaixiao/outline.js 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
commands.js 776 Bytes
一键复制 编辑 原始数据 按行查看 历史
import isFunction from './utils/types/isFunction'
class Commands {
constructor() {
this.commands = []
}
get(name) {
return this.commands.find((cmd) => cmd.name === name)
}
add(command) {
this.commands.push(command)
return this
}
del(name) {
const commands = this.commands
const command = commands.find((cmd) => cmd.name === name)
const index = command ? commands.indexOf(command) : -1
if (index > -1) {
commands.splice(index, 1)
}
return this
}
clear() {
this.commands = []
return this
}
execute(name) {
const command = this.commands.find((cmd) => cmd.name === name)
if (isFunction(command?.execute)) {
command.execute()
}
return this
}
}
export default Commands
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/liming0101/outline.js.git
[email protected]:liming0101/outline.js.git
liming0101
outline.js
outline.js
master

搜索帮助