{"size": 1073, "ext": "js", "max_stars_repo_path": "old/example9.js", "max_stars_repo_name": "abhocetabhac/thud-clunk", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "old/example9.js", "max_issues_repo_name": "abhocetabhac/thud-clunk", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "old/example9.js", "max_forks_repo_name": "abhocetabhac/thud-clunk", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 33.53125, "max_line_length": 78, "alphanum_fraction": 0.7120223672}
// Usage:
//   node ./example9 testfile2.txt testfile1.txt
//
// Nested thunks.

const myFiles = process.argv.slice(2);

const
  fs = require('fs'),
  thunkify = require('./thunkify9');

const gnReadFile = thunkify.generatorFactory(fs.readFile);

const fnRender = function(input) {
  console.log('');
  console.log(input);
};
// Nesting thunks may be implemented in two way:
// 1) Directly providing the child generator to the parent one.
const gnRender1 = thunkify.generatorFactory(gnReadFile, fnRender);
const render1 = thunkify.factory(gnRender1); // Named thunk caller.

for (let i = 0, len = myFiles.length; i < len; i++)
  render1(myFiles[i], 'utf-8'); // [5, 45...]

// 2) Alternatively, providing the child thunk caller to the parent generator.
//    Requires explicitly telling the generator it is parent of a thunk.
const readFile = thunkify.factory(gnReadFile);
const gnRender2 = thunkify.generatorFactory(readFile, fnRender, true);
const render2 = thunkify.factory(gnRender2); 
for (let i = 0, len = myFiles.length; i < len; i++)
  render2(myFiles[i], 'utf-8');