string-transformer
A module helps you transform an ES2016 template literals into concatenated strings, or reverse it back
an internal tool used by vscode-string-transformer
Install
npm i string-transformer
Usage
//convert ES2015 template literals into concatenated strings
import { toConcatenatedStrings } from 'string-transformer';
const es6string = '`test1${name}to${age}`';
const result = toConcatenatedStrings(es6string, '\'');
console.log('\'test1\' + name + \'to\' + age' === result);
//convert ES5 concatenated strings into template literals
import { toTemplateLiteral } from 'string-transformer';
const es5string = '\'test1\' + name + \' ok\'';
const result = toTemplateLiteral(es5string, '\'');
console.log('`test1${name} ok`' === result);