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

1.0.0 • Public • Published

string-transformer

NPM version

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);

LICENSE

GPL v3 License

Dependencies (0)

    Dev Dependencies (6)

    Package Sidebar

    Install

    npm i string-transformer

    Weekly Downloads

    2

    Version

    1.0.0

    License

    GPL-3.0

    Last publish

    Collaborators

    • howard.zuo