alignment
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

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

/alignment/

    Package Sidebar

    Install

    npm i alignment

    Weekly Downloads

    3

    Version

    0.0.1

    License

    MIT

    Last publish

    Collaborators

    • blakeembrey