-
Notifications
You must be signed in to change notification settings - Fork 19
/
chunk.js
40 lines (35 loc) · 917 Bytes
/
chunk.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
/* jshint node: true */
/* jshint jquery: true */
/* jshint esversion: 6 */
"use strict";
/**
* Chunk class
*
* Download, check last downloaded chunk
* @params Nothing
* @return Chunk object
*/
var fs = require( "fs" );
var request = require( "request" );
class Chunk {
/**
* Parse JSON and send it to callback
*
* @params Data to parse, callback
* @return Send parsed JSON to callback
*/
static loadJSON( data, chunkID, callback ) {
try {
data = JSON.parse( data, 'utf8' );
// If we reached the top and next_change_id is null
if ( !data.next_change_id ) {
console.log( "Top reached, waiting" );
} else {
callback( data );
}
} catch ( e ) {
console.log( "Error occured, retrying: " + e );
}
}
}
module.exports = Chunk;