mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-20 20:49:15 +00:00
refactor(bot): ✨ improvement refactor for get cbs
This commit is contained in:
@@ -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}`
|
||||
|
||||
Reference in New Issue
Block a user