JavaScript RORO模式:对象参数与返回值的艺术

27 阅读1分钟

Javascript RORO 模式

函数应始终接受对象作为其参数,并且应始终返回对象作为其结果。

async function runProcess({ processName }) {
  // run process on your server
  // maybe you decide to cache the results of this process running
  return { result, wasCached };
};