(db, doc, diffFun)
| 753 | } |
| 754 | |
| 755 | function tryAndPut(db, doc, diffFun) { |
| 756 | return db.put(doc).then(function (res) { |
| 757 | return { |
| 758 | updated: true, |
| 759 | rev: res.rev |
| 760 | }; |
| 761 | }, function (err) { |
| 762 | /* istanbul ignore next */ |
| 763 | if (err.status !== 409) { |
| 764 | throw err; |
| 765 | } |
| 766 | return upsert(db, doc._id, diffFun); |
| 767 | }); |
| 768 | } |
| 769 | |
| 770 | var thisAtob = function (str) { |
| 771 | return atob(str); |