wordcount-stream

wc stream

Usage no npm install needed!

<script type="module">
  import wordcountStream from 'https://cdn.skypack.dev/wordcount-stream';
</script>

README

wordcount-stream

Build Status npm install

a stream that acts like wc

usage

var wcStream = require('wordcount-stream')

var wc = wcStream()

wc.write('tu tu') // ->
// {
//     characters: 5
//   , words: 2
//   , lines: 1
// }

notes

optionally accepts a callback as the only argument. if provided, counts will not be streamed as received, but instead the total will be passed to the callback (in the same form as outlined above).

var wcStream = require('wordcount-stream')

var wc = wcStream(done)

wc.write('tu ')
wc.write('tu')
wc.end()

function done(data) {
  console.log(data) // ->
  // {
  //     characters: 5
  //   , words: 2
  //   , lines: 1
  // }
}

license

MIT