ln-stream

for-each line processor for a too big data

Usage no npm install needed!

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

README

ln-stream

for each line processor

attach proc for a line and defer the post-processor

lnstream = require('ln-stream')
lnstream(filename, proc, defer)

wc-like program

lnstream = require 'ln-stream'

lines = 0
words = 0
chars = 0

# processer for each line
proc = (line) ->
  lines += 1
  words += line.split ' '
               .length
  chars += line.length

# after the all lines
defer = () ->
  console.log "%d %d %d", lines, words, chars

lnstream './README.md', proc, defer

# => 36 120 504