如何重写这个嵌套调用设置使用脂肪箭头es6语法?



In 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);
});
});
});

如何将其转换为ES6胖箭头语法?我试着寻找一个在线转换器,但没有找到。

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

如果它是一个独立的函数,你会写

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

最新更新