简体   繁体   English

如何使用胖箭头 es6 语法重写此嵌套调用以设置?

[英]How to rewrite this nested call to set using fat arrow es6 syntax?

In https://github.com/yeahoffline/redis-mock/blob/master/test/client/redis-mock.keys.test.js :https://github.com/yeahoffline/redis-mock/blob/master/test/client/redis-mock.keys.test.js

  beforeEach(function (done) {
    r.set("hello", "test", function () {
      r.set("hallo", "test", function () {
        r.set("hxlo", "test", done);
      });
    });
  });

What is the way to convert this to ES6 fat arrow syntax?将其转换为 ES6 粗箭头语法的方法是什么? I tried looking for an online converter but failed to find one.我尝试寻找在线转换器,但没有找到。

  beforeEach((done) => {
    r.set("hello", "test", () => {
      r.set("hallo", "test", () => {
        r.set("hxlo", "test", done);
      });
    });
  });

If it was a standalone function you would write如果它是一个独立的 function 你会写

const setHellos = (done) => {.... }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM