var fd = use('fd') var time = use('time') var blob = use('blob') return { test_chunkread: function() { // Create temp file var tmp = "chunk_test.tmp" var f = fd.open(tmp, 'w') var bigdata = "" for(var i=0; i<100; i++) bigdata += "HelloWorld" // 1000 bytes fd.write(f, bigdata) fd.close(f) var data = new blob var st = time.number() var f2 = fd.open(tmp, 'r') var chunksize = 1024 // reduced for test while(true) { var chunk = fd.read(f2, chunksize); data.write_blob(chunk); // chunk.length is in bits, chunksize is bytes? // fd.read usually takes bytes. Blob.length is bits. // If chunk is blob, length is bits. // fd.read returns blob. if (chunk.length < chunksize * 8) break; } fd.close(f2) log.console(`read took ${time.number()-st}`) fd.unlink(tmp) } }