New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

journaling-hash

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

journaling-hash - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

55

index.js

@@ -6,37 +6,7 @@ var ImmutableHash = require('immutable-hash');

var lineReader = function(){
var buffer = '';
return through2(function(chunk, enc, cb){
buffer += chunk.toString();
var lineReader = require('through2-linereader');
var lineWriter = require('through2-linewriter');
var JSONReader = require('through2-jsonreader');
var JSONWriter = require('through2-jsonwriter');
var lines = buffer.split('\n');
buffer = lines.pop();
var self = this;
lines.forEach(function(line){
self.push(line);
});
cb();
}, function(cb){
this.push(buffer);
cb();
});
};
var JSONReader = function(){
return through2.obj(function(chunk, enc, cb){
chunk = chunk.toString();
var err = null;
try {
chunk = JSON.parse(chunk);
} catch (error) {
err = error;
chunk = null;
}
cb(err, chunk);
});
};
var readJournal = function(journalPath, callback){

@@ -50,3 +20,3 @@

})
.pipe(lineReader())
.pipe(lineReader(true))
.pipe(JSONReader())

@@ -75,9 +45,12 @@ .on('error', function(err){

self.journalWriteStream = fs.createWriteStream(self.journalPath, {
flags: newFile ? 'w' : 'a',
encoding: 'utf8'
});
self.journalWriteStream = JSONWriter();
self.journalWriteStream
.pipe(lineWriter())
.pipe(fs.createWriteStream(self.journalPath, {
flags: newFile ? 'w' : 'a',
encoding: 'utf8'
}));
if (newFile && hasData) {
self.journalWriteStream.write(JSON.stringify(hash.toJSON())+'\n', 'utf8', function(){
self.journalWriteStream.write(hash.toJSON(), function(){
callback(self);

@@ -106,3 +79,3 @@ });

promise = new Promise(function(resolve){
self.journalWriteStream.write(JSON.stringify(diff)+'\n', 'utf8', resolve);
self.journalWriteStream.write(diff, resolve);
});

@@ -109,0 +82,0 @@ } else {

{
"name": "journaling-hash",
"version": "0.0.2",
"version": "0.0.3",
"description": "Immutable hash that can back itself up to a file and rebuild itself",

@@ -27,4 +27,8 @@ "main": "index.js",

"immutable-hash": "^0.1.6",
"through2": "^0.6.3"
"through2": "^0.6.3",
"through2-jsonreader": "0.0.1",
"through2-jsonwriter": "0.0.1",
"through2-linereader": "0.0.1",
"through2-linewriter": "0.0.1"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc