Skip to content

Instantly share code, notes, and snippets.

@nolanlawson

nolanlawson/ascript.js

Forked from calvinmetcalf/ascript.js
Last active Aug 29, 2015
Embed
What would you like to do?
var start = document.getElementById('start');
var stuff = document.getElementById('stuff');
var remote = new PouchDB('http://registry.npmjs.org/', {cache: true});
var local = new PouchDB('npm');
start.addEventListener('click', function (){
remote.info().then(function (a) {
return a.doc_count;
}).then(function (count) {
remote.replicate.to(local, {
batch_size: 100
}).on('change', function (change) {
stuff.innerText = change.docs_written + ' out of ' + count;
}).on('complete', function () {
stuff.innerText = change.docs_written + ' done'
});
});
});
<div id="stuff"></div>
<button id="start">start</button>
<script src="//pouchtest.com/couchdb/pouchdb_builds/e8a764e9a58da8e8f26a069df5d75cc6f2acd8a7/pouchdb.min.js"></script>
<script src="ascript.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment