Skip to content

Commit 678557c

Browse files
committed
Refactor code to use arrow functions
1 parent 9b0dfec commit 678557c

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

lib/index.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
function createSleepPromise(timeout) {
2-
return new Promise(function(resolve) {
2+
return new Promise(resolve => {
33
setTimeout(resolve, timeout);
44
});
55
}
66

77
function sleep(timeout) {
88
// Pass value through, if used in a promise chain
99
function promiseFunction(value) {
10-
return createSleepPromise(timeout).then(function() {
11-
return value;
12-
});
10+
return createSleepPromise(timeout).then(() => value);
1311
}
1412

15-
var sleepPromise = createSleepPromise(timeout);
13+
const sleepPromise = createSleepPromise(timeout);
1614

1715
// Normal promise
18-
promiseFunction.then = function() {
19-
return sleepPromise.then.apply(sleepPromise, arguments);
20-
};
16+
promiseFunction.then = (...args) => sleepPromise.then(...args);
2117
promiseFunction.catch = Promise.resolve().catch;
2218

2319
return promiseFunction;

0 commit comments

Comments
 (0)