- Current implementation is known as streams2.
- Introduced in node v0.10.
- "suck" streams instead of "spew" streams.
- Instead of
data
events spewing, callread()
to pull data from source. - When there isn't any data to consume, then
read()
will return undefined. - Adding a
data
event listener will switch the Readable stream into "old mode", where data is emitted as soon as it is available rather than waiting for you to callread()
to consume it. This requires you to handle backpressure problems manually. - The
pipe
method helps write less code and handles back-pressure. - If you add an
end
listener and don't everread()
orpipe()
, it'll never emitend
.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var crypto = require("crypto"); | |
var EncryptionHelper = (function () { | |
function getKeyAndIV(key, callback) { | |
crypto.pseudoRandomBytes(16, function (err, ivBuffer) { | |
var keyBuffer = (key instanceof Buffer) ? key : new Buffer(key) ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Just copy and paste the lines below (all at once, it won't work line by line!) | |
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY! | |
function abort { | |
echo "$1" | |
exit 1 | |
} | |
set -e |