replay
Version:
When API testing slows you down: record and replay HTTP responses like a boss
36 lines (30 loc) • 741 B
text/coffeescript
class Chain
append: (proxy)->
fallback =
if
.next = fallback
= fallback
||= fallback
return this
prepend: (proxy)->
fallback =
fallback.next =
= fallback
||= fallback
return this
_fallback: (proxy)->
fallback = (request, callback)=>
proxy request, (error, response)=>
if error || response
callback error, response
return
if fallback.next
fallback.next request, callback
else
callback null
return fallback
clear: ->
= = null
.__defineGetter__ "start", ->
return
module.exports = Chain