-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod.js
42 lines (34 loc) · 884 Bytes
/
mod.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { connect, crocks } from './deps.js';
import copy from './copy.js';
const { Async } = crocks;
const FINISHED = '__FINISHED__';
if (Deno.args.length !== 2) {
console.log(`
Welcome to hyper-copy!
hyper-copy can copy one hyper data service to another hyper data service
using the hyper connection strings.
Usage:
hyper-copy $SRC $TARGET
`);
Deno.exit();
}
const [SRC, TARGET] = Deno.args;
const [src, target] = [connect(SRC), connect(TARGET)];
const list = Async.fromPromise(src.data.list);
const bulk = Async.fromPromise(target.data.bulk);
const cp = copy(list, bulk);
let key = '';
const BATCH = 1001;
for (let i = 0; i < Infinity; i++) {
try {
key = await cp(BATCH, key).toPromise();
if (key === FINISHED) {
console.log('Finished Copy!');
break;
}
} catch (err) {
console.log(err);
break;
}
console.log('Batch: ', i);
}