refactor(bot): improvement refactor for get cbs

This commit is contained in:
Leifer Mendez
2022-12-30 13:36:09 +01:00
parent a6f4aa8d1e
commit c62af73c16
3 changed files with 51 additions and 20 deletions

View File

@@ -8,7 +8,7 @@ class FlowClass {
if (!Array.isArray(_flow)) throw new Error('Esto debe ser un ARRAY')
this.flowRaw = _flow
this.getAllCb(this.flowRaw)
this.allCallbacks = this.parseCallBacks(this.flowRaw)
const mergeToJsonSerialize = Object.keys(_flow)
.map((indexObjectFlow) => _flow[indexObjectFlow].toJson())
@@ -21,12 +21,11 @@ class FlowClass {
* Buscar y aplanar todos los callbacks
* @param {*} inFlow
*/
getAllCb = (inFlow) => {
this.allCallbacks = inFlow
parseCallBacks = (inFlow) =>
inFlow
.map((cbIn) => cbIn.ctx.callbacks)
.flat(2)
.map((c, i) => ({ callback: c?.callback, index: i }))
}
find = (keyOrWord, symbol = false, overFlow = null) => {
keyOrWord = `${keyOrWord}`