UNPKG

@amplitude/ampli

Version:

Amplitude CLI

14 lines (13 loc) 598 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const parser_1 = require("./parser"); function stripCommentsAndStrings(codeFactory, replacer = ' ') { const parseResult = parser_1.default(codeFactory); return parseResult.segments.map(s => { const segmentText = parseResult.source.slice(s.startIndex, s.startIndex + s.length).join(''); return s.segmentType === 'comment' || s.segmentType === 'string' ? segmentText.replace(/[^\n\r]/gu, replacer) : segmentText; }).join(''); } exports.default = stripCommentsAndStrings;