Skip to content

Instantly share code, notes, and snippets.

@jovey-zheng
Created September 16, 2017 07:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jovey-zheng/f19718037c6111d3c749bb128154ac9c to your computer and use it in GitHub Desktop.
Save jovey-zheng/f19718037c6111d3c749bb128154ac9c to your computer and use it in GitHub Desktop.
Sync apply function
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