
(async () => {
  const assert = require('assert')
  const parse = require('..')
  const generate = require('csv-generate')
  // Create a readable input stream, could be `fs.createReadStream`
  const input = generate({
    length: 10000
  })
  // Initialise the parser by generating random records
  const parser = input.pipe(parse())
  // Iterate through each records
  let count = 0
  for await (const record of parser) {
    count++
  }
  // Validation
  assert.strictEqual(count, 10000)
})();

@@ -1,22 +1,5 @@
 %0A
-(async () =%3E %7B%0A  
 cons
@@ -30,41 +30,10 @@
 rt')
+;
 %0A
-  const parse = require('..')%0A  
 cons
@@ -72,126 +72,102 @@
 te')
-%0A  // Create a readable input stream, could be %60fs.createReadStream%60%0A  const input = generate(%7B%0A    length: 10000%0A  %7D)
+;%0Aconst parse = require('..');%0A%0A// Parameters%0Aconst wait = 100;%0Alet count = 0;%0A%0A(async () =%3E %7B
 %0A  /
@@ -240,26 +240,143 @@
 r = 
-input
+generate(%7B%0A    high_water_mark: 64 * 64,%0A    length: 1000%0A  %7D)
 .pipe(
+%0A    
 parse()
+%0A  )%0A  // Report start%0A  process.stdout.write('start%5Cn'
 )%0A  
@@ -411,24 +411,8 @@
 rds%0A
-  let count = 0%0A
   fo
@@ -464,63 +464,402 @@
 +%0A  
-%7D%0A  // Validation%0A  assert.strictEqual(count, 10000)%0A%7D)()
+  // Report current line%0A    process.stdout.write(%60$%7Bcount%7D $%7Brecord.join(',')%7D%5Cn%60)%0A    // Fake asynchronous operation%0A    await write()%0A  %7D%0A  // Report end%0A  process.stdout.write('...done%5Cn')%0A  // Validation%0A  assert.strictEqual(count, 10000)%0A%7D)()%0A// A fake asynchronous write function%0Aconst write = function()%7B%0A  return new Promise((resolve) =%3E setTimeout(function()%7B%0A    resolve()%0A  %7D, 100))%0A%7D
 ;%0A

update iterator sample