0.3.2 • Published 2 years ago

indent-transformer v0.3.2

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

indent-transformer

Using Node's Streams, this package takes a file with indentations and converts it into a stream with "IN" (INdent), "DE" (DEdent) or "NO" (NOdent) followed by a space.

Usage

import _transformStream from 'indent-transformer'
const transformStream = _transformStream(opts)

Options

lineNoPrecedesIndent: true | false

If true, line numbers will be printed before the indent indicator: 1|NODENT ...

Output

With line numbers first:

1|NODENT script. 2|INDENT if (foo) { 4|INDENT bar(); 6|DEDENT } 99999|DEDENT

With line numbers second:

NODENT1 script. INDENT2 if (foo) { INDENT4 bar(); DEDENT6 } DEDENT99999 

Test

npm test

Debugging

Prefix the command with "DEBUG='indent-transformer'".

Example:

DEBUG='indent-transformer' node src/index.js test/script.whitespace.in -

TODO

  1. Allow for no line numbers to be in output stream
  2. Switch to TAP for testing -- currently uses Mocha and doesn't have code coverage
  3. Replace Minimist with @foo-dog/utils

Undocumented Features

Might disappear at any time

Call index.js with an input file and output file. "-" for the output file prints to stdout.

node src/index.js test/script.whitespace.in -

Whether the line number prefixes the indentation indicator can be changed:

node src/index.js test/script.whitespace.in - true

Issues

I currently limit the number of lines to 99,998. This is purely arbitrary and can be increased if needed.

Build

npm run build

Publish

npm version [major|minor|patch]

npm publish --access public