-
-
Notifications
You must be signed in to change notification settings - Fork 770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prepare 5 release #1768
Prepare 5 release #1768
Conversation
Explain how to update to use the default sandbox
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine, though I have only casually glanced over it (most is known from earlier).
Thanks Morgan! One thing I noticed: The documentation for fake I remember that we talked about this and thought we already fixed the docs, but somehow that seems to have went under the radar. Unfortunately I can’t make that contribution myself from where I currently work ¯_(ツ)_/¯ |
79cc3ec
to
84a04d1
Compare
@mantoni I've pushed an extra commit to amend the documentation and provide a better example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍 Nice work, thank you!
module.exports = process.nextTick; | ||
} | ||
|
||
if (!hasNextTick && hasSetImmediate) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in terms of async scheduling, nextTick
and setImmediate
aren't exactly the same - nextTick
will append the call to the current spin of the loop, and setImmediate
schedules it for the next, whenever that happens. Maybe Promise.resolve().then(callback)
would be closer, as that will (afaik) do the same thing as nextTick
...? It's subtle, but it might be closer to the intended semantics.
ie:
function ping(m){
return function(){
console.log(m)
}
}
ping('start')()
setImmediate(ping('immediate'))
ping('start2')()
setTimeout(ping('timeout'),0)
ping('start3')()
process.nextTick(ping('tick'))
ping('start4')()
Promise.resolve().then(ping('promise'))
ping('start5')()
gives:
start
start2
start3
start4
start5
tick
promise
immediate
timeout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it'll be slightly faster when making lots of calls too.
This method was added in sinon v3.10.0: sinonjs/sinon#1515 and a deprecation warning for sinon.sandbox.create was added in sinon v5.0.1: - sinonjs/sinon#1768 - sinonjs/sinon@4fc7c65d#diff-7ac78866bb2aab0e4513c3e57f189c88R50
This PR contains a rewritten branch of
next
, most notable changes aresandbox
onsinon
fake
sinon.replace*
methodsspy.reset