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

curlyfy

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

curlyfy

Adds curly brackets to a whitespace indented string.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

curlyfy

curlyfy adds curly brackets to a whitespace indented string like this:

/* input */
a
    b
        c
            d
            e
    f
/* output */
a {
    b {
        c {
            d
            e
        }
    }
    f
}

It handles some special cases too:

/* input and output, no curly brackets added */

// trailing opening curly bracket
a = {
  b: c
}

// trailing opening square bracket
a = [
  b,
  c
]

// trailing opening parentheses
fn(
  a,
  b,
  c)

// trailing comma
fn(a,
   b,
   c)

Usage

npm install --save curlyfy
var curlyfy = require('curlyfy');
var output = curlyfy(input [, options]);

Options

insertSemicolons: (default: false)

Support [JavaScript semicolon-less style] (https://docs.npmjs.com/misc/coding-style#semicolons) gotchas. Because we guess that if you ditched braces you will probably ditch semicolons too ;)

For example:

var output = curlyfy(input, {insertSemicolons: true})
/* input */
++i
--i
(x || y).doSomething()
[a, b, c].forEach(doSomething)
/* output */
;++i
;--i
;(x || y).doSomething()
;[a, b, c].forEach(doSomething)

TO-DO:

  • Handle trailing comments
  • Normalize indentations
  • Make special cases optional

FAQs

Package last updated on 25 Apr 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