Socket
Socket
Sign inDemoInstall

alignment

Package Overview
Dependencies
3
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    alignment

Naive alignment of a block with variable assignments


Version published
Weekly downloads
3
increased by200%
Maintainers
1
Install size
42.1 kB
Created
Weekly downloads
 

Readme

Source

Alignment

NPM version NPM downloads Build status Test coverage

Alignment does naive alignment of a block with variable assignments.

Installation

npm install alignment --save

Usage

Returns a tuple of the result text and cursor positions.

import { block } from 'alignment'

const result = block(`
var x = 10;
var backgroundImage = 'http://example.com';
`)

console.log(result)
// [
//   '\nvar x               = 10;\nvar backgroundImage = \'http://example.com\';\n',
//   [ [ 1, 20 ], [ 2, 20 ] ]
// ]

Caveats:

  • Currently only supports \n line endings
  • True automatic alignment is difficult to achieve in a language agnostic way
    • Handling alignment across strings
    • Hanlding alignment across comments

License

MIT

Keywords

FAQs

Last updated on 24 Feb 2016

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