🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

esformatter-dot-notation

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

esformatter-dot-notation

esformatter plugin for transforming object bracket usage to dot notation

latest
Source
npmnpm
Version
1.3.1
Version published
Weekly downloads
5.2K
-17.42%
Maintainers
1
Weekly downloads
 
Created
Source

esformatter-dot-notation

esformatter plugin for transforming object bracket usage to dot notation

NPM Version NPM Downloads Build Status

esformatter-dot-notation is a plugin for esformatter meant to convert accessing object properties with brackets into dot notation where valid.

This module uses unquoted-property-validator which uses Mathias Bynens implementation in order to validate if a property name is a valid identifier name and can be used with dot notation.

That means invalid identifiers will not be converted and your code is safe for transformations (see tests).

Turn this:

someObject['property'] = true;

into:

someObject.property = true;

Installation

$ npm install esformatter-dot-notation --save-dev

Config

Newest esformatter versions autoload plugins from your node_modules See this

Add to your esformatter config file:

{
  "plugins": [
    "esformatter-dot-notation"
  ]
}

Or you can manually register your plugin:

var dotNotation = require('esformatter-dot-notation');
// register plugin
esformatter.register(dotNotation);

Usage

var fs = require('fs');
var esformatter = require('esformatter');
//register plugin manually
esformatter.register(require('esformatter-dot-notation'));

var str = fs.readFileSync('someKewlFile.js').toString();
var output = esformatter.format(str);
//-> output will now contain the formatted string

See esformatter for more options and further usage.

License

MIT @Gilad Peleg

Keywords

esformatter

FAQs

Package last updated on 28 May 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