#!/usr/bin/env node

var sc = require('skale-engine').context();

var file = process.argv[2] || '/etc/hosts';

sc.textFile(file)
  .flatMap(line => line.split(' '))
  .map(word => [word, 1])
  .reduceByKey((a, b) => a + b, 0)
  .count().then(console.log)

#!/usr/bin/env node

var sc = require('skale-engine').context();

var file = process.argv[2] || '/etc/hosts';

sc.textFile(file)
  .flatMap(line => line.split(' '))
  .map(word => [word, 1])
  .reduceByKey((a, b) => a + b, 0)
  .count().then(function (res) {
  	console.log(res);
	sc.end();
  });

Add sc.end() to exit after results. Suggested by @tfauck.
Add sc.end() to exit after results. Suggested by @tfauck.
