Sha256: 89acd653f2afd1579a9f5dcf06d9e176655d0d6f30370ab6b678db51c172a9fa
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * Change the escape characters to convert the given string contents from one * quote style to another. */ function convertStringEscaping(fromQuote, toQuote, string) { if (fromQuote === toQuote) { return string; } let result = ''; for (let i = 0; i < string.length; i++) { // We always start in an unescaped position, and advance forward if we see // an escape. if (string[i] === '\\') { if (string[i + 1] === fromQuote) { // No need to escape anymore. result += string[i + 1]; i++; } else { // Copy both characters (or just one if we're at the end). result += string.slice(i, i + 2); i++; } } else if (string[i] === toQuote) { result += `\\${string[i]}`; } else if (string.slice(i, i + 2) === '${' && toQuote === '`') { result += `\\${string[i]}`; } else { result += string[i]; } } return result; } exports.default = convertStringEscaping; //# sourceMappingURL=convertStringEscaping.js.map
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wice_grid-7.1.0 | node_modules/@resugar/codemod-strings-template/src/convertStringEscaping.js |