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

krasota

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

krasota

Syntactic transformations of JavaScript code, with taking care of whitespaces and comments.

  • 0.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13
Maintainers
1
Weekly downloads
 
Created
Source

What is this?

krasota.js is trying to save the world. It provides the ability to carry out the syntactic transformation JavaScript code. Conversions can be both for the protection coding style, and for more complex refactorings logic.

How to use?

Command-line

Note: For using from command-line you should install it globally -- npm install -g krasota.

$ krasota --help

Usage:
  krasota [OPTIONS]


Options:
  -h, --help : Help
  -v, --version : Version
  -i INPUT, --input=INPUT : Input file (default: stdin)
  -o OUTPUT, --output=OUTPUT : Output file (default: stdout)
  -b BEAUTIFIERS, --beautifier=BEAUTIFIERS : Local or global path to beautifier module, can be used many times

Examples:

$ krasota -i tests/split-vars.js -b krasota/lib/beautifiers/split-vars
$ krasota -i tests/join-vars.js -b krasota/lib/beautifiers/trailing-whitespaces -b krasota/lib/beautifiers/join-vars
$ krasota -i my-file.js -o my-beauty-file.js -b ./local/path/to/my/beautifier

See below for available build-in beautifiers.

API

Note: If you are using krasota programatically you should not install it globally, it's enough to declare depends in package.json.

COA

Because of using COA all command-line interface available through require('krasota').COA. Example:

require('krasota').COA
    .invoke({
        input: 'tests/join-vars.js',
        beautifiers: [ 'lib/beautifiers/trailing-whitespaces', 'krasota/lib/beautifiers/join-vars' ]
    })
OMeta

You can use krasota through the require('krasota') in terms of raw OmetaJS-grammas. Take a look to the tests/tests.js for example of usage.

Which beautifiers are available?

There are not many proof-of-concept beautifiers, but it's complex enough for using as samples for your own.

krasota/lib/beautifiers/always-semicolons

Force insert semicolons (you know epic thread). Example:

beforeafter
clearMenus()
!isActive && $parent.toggleClass('open')
clearMenus();
!isActive && $parent.toggleClass('open');

krasota/lib/beautifiers/join-vars

Join multiply consecutive var statements into one var statement with multiply assigns. Example:

beforeafter
var a = 1;
var b = 2;
var c = 3;
var a = 1,
    b = 2,
    c = 3;

krasota/lib/beautifiers/split-vars

Split var statements with multiply assigns into multiply consecutive var statements. Example:

beforeafter
var a = 1,
    b = 2,
    c = 3;
var a = 1;
var b = 2;
var c = 3;

krasota/lib/beautifiers/trailing-whitespaces

Remove trailing whitespaces (it's pretty simple without any examples).

Tests

Run make tests for tests. For development version tests run make tests ENV=development.

Other projects

FAQs

Package last updated on 27 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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