使用匿名/箭头函数回调分配速记

Ale*_*lls 1 javascript node.js arrow-functions

我有这个代码示例:

 before('get all users', h => {
    return getAllUsers().then(function (users) {
      return h.supply.users = users;
    });
  });
Run Code Online (Sandbox Code Playgroud)

我正在寻找一些速记,这是我能做的最好的吗?

 before('get all users', h => {
    return getAllUsers().then(v => (h.supply.users = v));
 });
Run Code Online (Sandbox Code Playgroud)

我在想,也许我们可以使用一些替代的分配技巧.

Mel*_*hia 5

你可以在一行中完成

   before('get all users', h => getAllUsers().then(v => h.supply.users=v));
Run Code Online (Sandbox Code Playgroud)