Warning: this is an htmlized version!
The original is across this link,
and the conversion rules are here.
#!/usr/bin/env lua50
-- Example:
--   ls /tmp/ | pump.lua 10 2 6
--   (eev "ls /tmp/ | pump.lua 10 2 6")
--
-- pump.lua outputs 10 bytes, then sleeps for 2 seconds, then ouputs
-- more 6 bytes, then sleeps 2 seconds more, then outputs 6 more
-- bytes, etc, until the input is exhausted; then it exits.

load_posix()
eof = false

pump = function (n)
    n = tonumber(n)
    local buffer = io.read(n)
    if buffer then io.write(buffer); io.output():flush() end
    if not buffer or strlen(buffer) < n then eof = true end
  end

foo = function(n1, s, n2)
    pump(n1)
    if eof then return end
    while 1 do
      posix.sleep(s)
      pump(n2)
      if eof then return end
    end
  end

-- Suppress error messages, just exit.
-- Without the pcall when we kill the script with a ^C it gives this
-- annoying message: "lua50: (error with no message)".
-- (find-luamanualw3m "#pdf-pcall")
--     foo(arg[1], arg[2], arg[3])
pcall(foo, arg[1], arg[2], arg[3])