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.
import _transformStream from 'indent-transformer'
const transformStream = _transformStream(opts)
lineNoPrecedesIndent: true | false
If true, line numbers will be printed before the indent indicator: 1|NODENT ...
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
npm test
Prefix the command with "DEBUG='indent-transformer'".
Example:
DEBUG='indent-transformer' node src/index.js test/script.whitespace.in -
- Allow for no line numbers to be in output stream
- Switch to TAP for testing -- currently uses Mocha and doesn't have code coverage
- Replace Minimist with @foo-dog/utils
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
I currently limit the number of lines to 99,998. This is purely arbitrary and can be increased if needed.
npm run build
npm version [major|minor|patch]
npm publish --access public