Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createReadableStreamFromString(s) {
const readable = new stream.Readable();
readable._read = function () {};
readable.push(s);
readable.push(null);
return readable;
}
function getReadable(stream) {
var s = stream;
if(typeof stream === "string") {
s = new Readable();
s._read = Function.prototype;
s.push(stream);
s.push(null);
}
return s;
}
function lock(password, object, filename, cb) {
let s = new stream.Readable();
s._read = function noop() {};
s.push(JSON.stringify(object));
s.push(null);
let out = fs.createWriteStream(filename);
out.on('error', function(e) {
cb(e);
});
out.on('finish', function() {
cb(null);
});
s.pipe(zlib.createGzip()).pipe(crypto.createCipher(algorithm, password)).pipe(
out);
}
function lock (password, object, filename, cb) {
var s = new stream.Readable();
s._read = function noop() {};
s.push(JSON.stringify(object));
s.push(null);
var out = fs.createWriteStream(filename);
out.on('error', function (e) {
cb(e);
});
out.on('finish', function () {
cb(null);
});
s.pipe(zlib.createGzip()).pipe(crypto.createCipheriv(algorithm, password, iv)).pipe(out);
}
function lock(password, object, filename, cb) {
var s = new stream.Readable();
s._read = function noop() {};
s.push(JSON.stringify(object));
s.push(null);
var out = fs.createWriteStream(filename);
out.on('error', function(e) {
cb(e);
});
out.on('finish', function() {
cb(null);
});
s.pipe(zlib.createGzip()).pipe(crypto.createCipher(algorithm, password)).pipe(
out);
}