Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

j_utils

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

j_utils - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

52

j_ngrep_filter.js
#!/usr/bin/env node
// var args = process.argv.slice(2)
var argv = require('minimist')(process.argv.slice(2));
var readline = require('readline');
var beautify = require("json-beautify");
var fileName = argv['_'][0]
var inputStream;
if(typeof fileName === 'string'){
inputStream = require('fs')
.createReadStream(fileName)
} else {
inputStream = process.stdin
}
var colors = require('colors');
colors.setTheme({

@@ -18,6 +27,2 @@ silly: 'grey',

var fs = require('fs');
var beautify = require("json-beautify");
var fileName = argv['_'][0]
console.log(argv)
var orOptions = argv['o']

@@ -32,10 +37,5 @@ if(orOptions && typeof orOptions === 'string' )

var file = fs.readFileSync(fileName).toString()
function removeDuplicateFilter(item, pos, self) {
return self.indexOf(item) == pos;
}
function printBlock(item) {
function beautifyJson(item) {
var splitted = item.split('\n.\n')

@@ -64,4 +64,2 @@ var header = splitted[0]

}
}

@@ -80,9 +78,23 @@

var res = file
.split('\n\n')
.filter(removeDuplicateFilter)
var rl = readline.createInterface({
input: inputStream,
// output: process.stdout
});
var alreadyPrintedBlocks = [];
var curBlock;
var lastLine;
rl.on('line', function (line) {
if(!line && !lastLine.index){
// console.log('\n ########### \n')
if(alreadyPrintedBlocks.indexOf(curBlock) === -1 ){
alreadyPrintedBlocks.push(curBlock)
printBlock(curBlock)
}
curBlock = ""
} else {
curBlock += '\n'+line
}
res
.forEach(beautifyJson)
lastLine = line
});
{
"name": "j_utils",
"version": "0.0.3",
"version": "0.0.4",
"description": "",

@@ -5,0 +5,0 @@ "repository": {

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