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

binary-cli

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

binary-cli - npm Package Compare versions

Comparing version 1.0.0 to 1.1.1

44

cli.js
#!/usr/bin/env node
'use strict';
const meow = require('meow');
const getStdin = require('get-stdin');
const logSymbols = require('log-symbols');
'use strict'
const meow = require('meow')
const getStdin = require('get-stdin')
const logSymbols = require('log-symbols')

@@ -13,2 +13,3 @@ const cli = meow(`

-d, --decode Decode binary-encoded string
-p, --plain Display output without log symbols
Examples

@@ -25,7 +26,12 @@ ~ ❯❯❯ binary foo

default: false
},
plain: {
type: 'boolean',
alias: 'p',
default: false
}
}
});
})
const input = cli.input[0];
const input = cli.input[0]

@@ -35,3 +41,3 @@ function binEncode (text) {

for (var i = 0; i < text.length; i++) {
bin += text[i].charCodeAt(0).toString(2) + " ";
bin += text[i].charCodeAt(0).toString(2) + " "
}

@@ -43,3 +49,3 @@ return bin

const re = '(?:[01]+)'
if (new RegExp(re, 'g').test(text)) return true;
if (new RegExp(re, 'g').test(text)) return true
else return false

@@ -52,3 +58,3 @@ }

bin.replace(/[01]+/g, function (i) {
ascii += String.fromCharCode(parseInt(i, 2));
ascii += String.fromCharCode(parseInt(i, 2))
})

@@ -62,6 +68,8 @@ return ascii

if (plaintext != 'Text doesn\'t seem to be binary-encoded') {
console.log(`${logSymbols.success} ` + plaintext)
const leading = (cli.flags["plain"]) ? `` : `${logSymbols.success} `
console.log(leading + plaintext)
} else {
console.log(`${logSymbols.error} Text doesn\'t seem to be binary-encoded`);
process.exit(1);
const leading = (cli.flags["plain"]) ? `` : `${logSymbols.error} `
console.log(leading + `Text doesn\'t seem to be binary-encoded`)
process.exit(1)
}

@@ -71,10 +79,10 @@ }

if (!input && process.stdin.isTTY) {
console.log('Enter string to binary encode/decode');
process.exit(1);
console.log('Enter string to binary encode/decode')
process.exit(1)
}
if (input) {
if (cli.flags["decode"]) {
display(binDecode(input));
display(binDecode(input))
} else {
display(binEncode(input));
display(binEncode(input))
}

@@ -84,7 +92,7 @@ } else {

if (cli.flags["decode"]) {
display(binDecode(stdin));
display(binDecode(stdin))
} else {
display(binEncode(stdin));
display(binEncode(stdin))
}
})
}
{
"name": "binary-cli",
"version": "1.0.0",
"version": "1.1.1",
"description": "Binary encode & decode a string, right from your terminal.",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -23,2 +23,3 @@ # binary-cli [![Build Status](https://travis-ci.org/k4m4/binary-cli.svg?branch=master)](https://travis-ci.org/k4m4/binary-cli)

-d, --decode Decode binary-encoded string
-p, --plain Display output without log symbols
Examples

@@ -25,0 +26,0 @@ ~ ❯❯❯ binary foo

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