Skip to content

Instantly share code, notes, and snippets.

@frohoff
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frohoff/4bed435923c95a0019a8 to your computer and use it in GitHub Desktop.
Save frohoff/4bed435923c95a0019a8 to your computer and use it in GitHub Desktop.
long stream chain test
var crypto = require('crypto')
var hashType = process.argv[2] || 'sha1'
var numHashes = parseInt(process.argv[3] || 1)
// init chain with stdout
var piped = process.stdout
for (var i = 0; i < numHashes; i++) {
// prepend chain with new hash
var hash = crypto.createHash(hashType)
hash.pipe(piped)
piped = hash
}
//pipe stdin into chain
process.stdin.pipe(piped)
@frohoff
Copy link
Author

frohoff commented May 20, 2014

$ cat longchaintest.js | node longchaintest.js sha1 10000 | xxd -ps

(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
(436 of these total)
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.

RangeError: Maximum call stack size exceeded
$

@frohoff
Copy link
Author

frohoff commented May 21, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment