Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add batch mode: trigger.start()

  • Loading branch information...
commit 6d77b3a0a9e8f4fc690e62546216fd388116deb1 1 parent 5e72712
@dominictarr authored
Showing with 13 additions and 2 deletions.
  1. +13 −2 index.js
View
15 index.js
@@ -47,14 +47,25 @@ module.exports = function (input, jobs, map, work) {
})
}
- input.pre(function (ch, add) {
+ function doHook (ch, add) {
var key = map(ch)
var hash = shasum(key)
if(!pending[hash])
add({key: Date.now(), value: key, type: 'put'}, jobs)
else
pending[hash] = (0 || pending[hash]) + 1
- })
+ }
+
+ input.pre(doHook)
+
+ //process the whole db as a batch
+ jobs.start = function () {
+ input.createReadStream()
+ .on('data', function (data) {
+ doHook(data, doJob)
+ })
+ return jobs
+ }
jobs.createReadStream().on('data', doJob)
jobs.post(doJob)
Please sign in to comment.
Something went wrong with that request. Please try again.