Multiline JavaScript Converter is a tool to convert strings into JavaScript safe text. It is able to account for new lines, special characters and able to produce multiple string types.
Multiline JavaScript Converter can also be used as an NPM library.
npm install --save-dev multilinejavascriptconverter
yarn install --save multilinejavascriptconverter
Inside your Node project:
var msc = require('multilinejavascriptconverter');
var input = [
'line1',
'line2',
'line3',
'line4',
'line5',
];
var output = msc.convertText('output', input, msc.ECMA5_DOUBLE, false, true, false, msc.TABS);
console.log(output);
/* Expected output:
var output = "line1" +
"line2" +
"line3" +
"line4" +
"line5"
*/
Note: All fields are required.
Field # | Field Name | Valid Values |
---|---|---|
1 | Variable name | Any string |
2 | Input variables | String separated by '\n' (Newline) or Array |
3 | String type | ECMA_DOUBLE/ECMA_SINGLE/ECMA6/JSON_DOUBLE |
4 | Add new lines | true/false |
5 | Trim whitespace | true/false |
6 | Semicolon (N/A for JSON_DOUBLE) | true/false |
7 | Spaces | TAB/SPACES_2/SPACES_4/SPACES_8 |
Below constants can be imported from the library:
- String types: ECMA_DOUBLE/ECMA_SINGLE/ECMA6/JSON_DOUBLE
- Space types: TAB/SPACES_2/SPACES_4/SPACES_8
- Download repository
- Run
npm install
- Run
npm run setup
to install dependencies
npm run build
npm run serve
npm run js
npm run js:build
npm run js:compile
npm run css
npm run html
npm run test
npm run linter
npm run mocha
Run the below the first time:
npm run selenium-setup
The below must be running every time tests are run:
npm run serve
node_modules/.bin/chromedriver
To run the tests run the below:
npm run nightwatch
- Skeleton - for basic CSS framework
- Babel - for converting to ECMA5 code for browser
- clipboard.js - for copying text to clipboard
- Browserify - for using require feature to enable better modularity of JavaScript
- PugJS - for HTML templating
- Mocha - for unit testing
- Chai - for assertions in Mocha
- Nightwatch - for E2E testing
- ESLint - for linting of JS files
- Github Actions - for CI and deployment
If you find any bugs or have any suggestions on how to improve Multiline JavaScript Converter please post in the Github issues.