🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

alignment

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

alignment

Naive alignment of a block with variable assignments

0.0.1
latest
Source
npm
Version published
Weekly downloads
6
100%
Maintainers
1
Weekly downloads
 
Created
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

align

FAQs

Package last updated on 24 Feb 2016

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