Created
September 16, 2017 07:12
-
-
Save jovey-zheng/f19718037c6111d3c749bb128154ac9c to your computer and use it in GitHub Desktop.
Sync apply function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syncApply ({timeout, fn, args = [], scope = this}) { | |
return new Promise((resolve, reject) => { | |
try { | |
setTimeout(() => { | |
resolve(fn.apply(scope, args)) | |
}, timeout) | |
} catch (err) { | |
reject(err) | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment