Skip to content

regular/never-give-up

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

never-give-up

const retry = require('dont-stop-believing')

let count = 5
function fun(a, b, c, cb) {
  console.log(b)
  
  if (count--) return cb(new Error('bah!'))
  cb(null, a, b, c)
}

const rf = retry(fun)

rf(1,2,3, (err, a, b, c) =>{
  console.log(err)
  console.log(b)
})
> node test.js

2
bah!, retrying in 1s 
2
bah!, retrying in 1s  (retry #1)
2
bah!, retrying in 1s  (retry #2)
2
bah!, retrying in 1s  (retry #3)
2
bah!, retrying in 1s  (retry #4)
2
null
2

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published