Socket
Socket
Sign inDemoInstall

esformatter-var-each

Package Overview
Dependencies
3
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    esformatter-var-each

Esformatter plugin that converts comma `var` statements into separate `var` statements


Version published
Weekly downloads
134
increased by67.5%
Maintainers
1
Install size
1.27 MB
Created
Weekly downloads
 

Readme

Source

esformatter-var-each Build status

Esformatter plugin that converts comma var statements into separate var statements

This was created to make obfuscated scripts more palatable. However, it should be a nice addition to your web development tasks.

Features:

  • Preserves last character of var's (e.g. var a, b; -> var a; var b;)
  • Maintain indentation level of var's

Getting Started

Install the module with: npm install esformatter-var-each

Then, register it as a plugin and format your JS:

// Load and register our plugin
var esformatter = require('esformatter');
var esformatterVarEach = require('esformatter-var-each');
esformatter.register(esformatterVarEach);

// Format our code
esformatter.format([
  'var a = \'hello\',',
  '    b = \'world\';'
].join('\n'));
// var a = 'hello';
// var b = 'world';

Alternatively, load it via format directly:

var esformatter = require('esformatter');
esformatter.format([
  'var a = \'hello\',',
  '    b = \'world\';'
].join('\n'), {
  plugins: [
    'esformatter-var-each'
  ]
});

Documentation

esformatter-var-each exposes exports.transform for consumption by esformatter.

esformatterVarEach.transform(ast)

Walk AST and splice in var statements.

Warning: This mutates nodes in place

  • ast AbstractSyntaxTree - Abstract syntax tree provided by esformatter

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via grunt and test via npm test.

Donating

Support this project and others by twolfson via gratipay.

Support via Gratipay

Unlicense

As of Nov 03 2014, Todd Wolfson has released this repository and its contents to the public domain.

It has been released under the UNLICENSE.

Keywords

FAQs

Last updated on 03 Aug 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc