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

esmall

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esmall - npm Package Compare versions

Comparing version 1.2.2 to 2.0.0

32

lib/index.js

@@ -16,2 +16,4 @@ /* Copyright 2016 Myles Borins

var babel = require('babel-core');
function minify(code, cb) {

@@ -22,27 +24,6 @@ if (typeof code !== 'string') {

}
try {
// remove comments
code = code.replace(/(\/\*([\s\S]*?)\*\/)|(\/\/(.*)$)/gm, '');
// remove any spaces after a semi colon
code = code.replace(/;\s+/g, ';');
// remove extra spaces around +
code = code.replace(/(\s+)?\+(\s+)?/g, '+');
// remove extra spaces around -
code = code.replace(/(\s+)?\-(\s+)?/g, '-');
// remove extra spaces around *
code = code.replace(/(\s+)?\*(\s+)?/g, '*');
// remove extra spaces around /
code = code.replace(/(\s+)?\/(\s+)?/g, '/');
// remove extra spaces around =
code = code.replace(/(\s+)?\=(\s+)?/g, '=');
// remove spaces at the begining
code = code.replace(/^\s+/, '');
}

@@ -53,3 +34,8 @@ catch (e) {

}
cb(null, code);
var result = babel.transform(code, {
presets: ['babili']
}).code;
cb(null, result);
return true;

@@ -56,0 +42,0 @@ }

{
"name": "esmall",
"version": "1.2.2",
"version": "2.0.0",
"description": "Pretty Naive",

@@ -16,2 +16,4 @@ "main": "lib/index.js",

"dependencies": {
"babel-core": "^6.21.0",
"babel-preset-babili": "0.0.9",
"chalk": "^1.1.3",

@@ -18,0 +20,0 @@ "concat-stream": "^1.5.2",

@@ -5,11 +5,5 @@ # esmall

## 📛 WARNING 📛
This is super jank, likely to break your code.
For best results use semi colons!
## How it works
Does a little [reggae](https://twitter.com/thealphanerd/status/764133752905883649)
Just a little wrapper around [babili][babili] with a little [reggae][reggae] to deal with comments

@@ -47,2 +41,5 @@ ## Using the cli

Apache v2.0
Apache v2.0
[babili][https://github.com/babel/babili]
[reggae][https://twitter.com/thealphanerd/status/764133752905883649]

@@ -21,9 +21,10 @@ /* Copyright 2016 Myles Borins

var code = `
var a = '123';
var b = '456';
var a = 213;
var b = 123;
var c = 123456;
console.log('a + b * c / d');
var d = 2134;
console.log(a + b * c / d);
`;
var expected = 'var a=\'123\';var b=\'456\';var c=123456;console.log(\'a+b*c/d\');';
var expected = 'var a=213,b=123,c=123456,d=2134;console.log(a+b*c/d);';

@@ -46,22 +47,9 @@ var licensedCode = `

var a = '123';
var b = '456'; // this comment should be removed
var c = 123456;
console.log('a + b * c / d');
var a = 213;
var b = 123;
var c = 123456;
var d = 2134
console.log(a + b * c / d);
`;
var multiSpaceSemiColon = `
var a = '123'; var b = '456'; // this comment should be removed
var c = 123456;
console.log('a +b * c / d');
`;
var excessiveSpaces = `
var a = '123'; var b = '456'; // this comment should be removed
var c = 123456;
console.log('a +
b * c / d');
`;
test('basic test', (t) => {

@@ -75,18 +63,2 @@ t.plan(2);

test('more than one space after semi', (t) => {
t.plan(2);
esmall(multiSpaceSemiColon, (err, result) => {
t.error(err);
t.equals(result, expected, 'we should be minified');
});
});
test('no excessive spaces', (t) => {
t.plan(2);
esmall(excessiveSpaces, (err, result) => {
t.error(err);
t.equals(result, expected, 'we should be minified');
});
});
test('no license', (t) => {

@@ -93,0 +65,0 @@ t.plan(2);

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