writable-counter

A writable stream that counts the number of times it has received data.

Usage no npm install needed!

<script type="module">
  import writableCounter from 'https://cdn.skypack.dev/writable-counter';
</script>

README

writable-counter

Creates writable streams that do nothing but count the number of times data has been passed to them.

Installing

npm install --save writable-counter

Usage

var streamArray = require("stream-array");
var WritableCounter = require('writable-counter');
var data = ["foo", "bar", "fizz", "baz"];

var counter = WritableCounter();

streamArray(data)
  .pipe(counter)  
  .on('finish', function() {
    console.log(counter.count); // logs 4 to the console
  });