How to concatenate strings returned by asynchronous methods into arrays or objects

how do the strings returned by the asynchronous method be spliced into arrays or objects each time?
is often encountered at work and has not been very good at processing.
all the code is copied from here.
vue teaches you to use decorator to achieve seamless embedding

.
export function Buried(target, funcName, descriptor) {
  let oriMethods = Object.assign({},target.methods),
      oriTarget = Object.assign({},target);
  // methods
  if(target.methods) {
    for(let name in target.methods) {
      target.methods[name] = function () {
        let result = oriMethods[name].call(this,...arguments);
        //  noBuried 
        if(typeof result === "string" && result.includes("noBuried")) {
          console.log(name + "");
        } else if(result instanceof Promise) {
          result.then(res => {
            if(typeof res === "string" && res.includes("noBuried")) { console.log(name + ""); return; };
            console.log("methods:" , name.toUpperCase ());
            this.$log(name);
          });
        }else{
          console.log("methods:" , name.toUpperCase ());
          this.$log(name);
        };
        return result;
      }
    }
  }
  // 
  const hookFun = (funName) => {
    target[funName] = function() {
      let result =  oriTarget[funName].call(this,...arguments);
      console.log("" + funName + ":", "VIEW");
      this.$log("VIEW");
      return result;
    }
  }
  //  view
  if (target.activated) {
    return hookFun("activated");
  } else if (target.created) {
    return hookFun("created");
  } else if (target.mounted) {
    return hookFun("mounted");
  };
}

apply as follows:

import { Buried } from "@/libs/decorators";

@Buried
methods: {
   ...
}

entry file settings:

Vue.prototype.$log = function leStatic (actiontype) {
  console.log(actiontype)
}

returns

getRegion                                  main.js?3479:22
setService                                 main.js?3479:22
setRegionDefalut                           main.js?3479:22
updateLogo                                 main.js?3479:22

will see that each time the returned string is a string. Can
process the returned string,
, into an array or an object?

ask for advice, thank you!


When you change

to console.log ([actiontype])
or emit, pass the array?

or have you received it and tidied it up? Or tidy it up when it triggers?


try the method Array.of ()

Menu