diff --git a/packages/flow-remove-types/index.js b/packages/flow-remove-types/index.js index 0ed1c0e2625..c6f974baab5 100644 --- a/packages/flow-remove-types/index.js +++ b/packages/flow-remove-types/index.js @@ -63,11 +63,14 @@ module.exports = function flowRemoveTypes(source, options) { var removedNodes = []; + var sourceBuffer = Buffer.from(source); + var context = { ast: ast, - source: source, + sourceBuffer: sourceBuffer, removedNodes: removedNodes, pretty: Boolean(options && options.pretty), + bytesAdded: 0 }; // Remove the flow pragma. @@ -85,10 +88,10 @@ module.exports = function flowRemoveTypes(source, options) { // Remove all flow type definitions. visit(ast, context, removeFlowVisitor); - return resultPrinter(options, source, removedNodes); + return resultPrinter(options, source, sourceBuffer, removedNodes, context.bytesAdded); }; -function resultPrinter(options, source, removedNodes) { +function resultPrinter(options, source, sourceBuffer, removedNodes, bytesAdded) { // Options var pretty = Boolean(options && options.pretty); @@ -98,32 +101,36 @@ function resultPrinter(options, source, removedNodes) { return source; } - var result = ''; + var buf = Buffer.alloc(sourceBuffer.length + bytesAdded); var lastPos = 0; + var offset = 0; // Step through the removed nodes, building up the resulting string. for (var i = 0; i < removedNodes.length; i++) { var node = removedNodes[i]; - result += source.slice(lastPos, startOf(node)); - lastPos = endOf(node); + var start = startOf(node); + var end = endOf(node); + offset += sourceBuffer.copy(buf, offset, lastPos, start); + lastPos = end; if (typeof node.__spliceValue === 'string') { - result += node.__spliceValue; + offset += buf.write(node.__spliceValue, offset); } if (!pretty) { - var toReplace = source.slice(startOf(node), endOf(node)); if (!node.loc || node.loc.start.line === node.loc.end.line) { - result += space(toReplace.length); + offset += buf.write(space(end - start), offset); } else { - var toReplaceLines = toReplace.split(LINE_RX); - result += space(toReplaceLines[0].length); + var toReplaceLines = sourceBuffer.toString('utf8', start, end).split(LINE_RX); + offset += buf.write(space(toReplaceLines[0].length), offset); for (var j = 1; j < toReplaceLines.length; j += 2) { - result += toReplaceLines[j] + space(toReplaceLines[j + 1].length); + offset += buf.write(toReplaceLines[j] + space(toReplaceLines[j + 1].length), offset); } } } } - return (result += source.slice(lastPos)); + offset += sourceBuffer.copy(buf, offset, lastPos, sourceBuffer.length); + + return buf.toString('utf8', 0, offset); }, generateMap: function() { return { @@ -324,17 +331,22 @@ function removeNode(context, node) { return false; } +var SPACE = ' '.charCodeAt(0); +var TAB = '\t'.charCodeAt(0); +var RETURN = '\r'.charCodeAt(0); +var NEWLINE = '\n'.charCodeAt(0); + function getPragmaNode(context, start, size) { - var source = context.source; + var source = context.sourceBuffer; var line = 1; var column = 0; for (var position = 0; position < start; position++) { var char = source[position]; - if (char === '\n') { + if (char === NEWLINE) { line++; column = 0; - } else if (char === '\r') { - if (source[position + 1] === '\n') { + } else if (char === RETURN) { + if (source[position + 1] === NEWLINE) { position++; } line++; @@ -354,10 +366,10 @@ function getPragmaNode(context, start, size) { } function getLeadingSpaceNode(context, node) { - var source = context.source; + var source = context.sourceBuffer; var end = startOf(node); var start = end; - while (source[start - 1] === ' ' || source[start - 1] === '\t') { + while (source[start - 1] === SPACE || source[start - 1] === TAB) { start--; } if (start !== end) { @@ -370,16 +382,16 @@ function getLeadingSpaceNode(context, node) { } function getTrailingLineNode(context, node) { - var source = context.source; + var source = context.sourceBuffer; var start = endOf(node); var end = start; - while (source[end] === ' ' || source[end] === '\t') { + while (source[end] === SPACE || source[end] === TAB) { end++; } // Remove all space including the line break if this token was alone on the line. - if (source[end] === '\n' || source[end] === '\r') { - if (source[end] === '\r' && source[end + 1] === '\n') { + if (source[end] === NEWLINE || source[end] === RETURN) { + if (source[end] === RETURN && source[end + 1] === NEWLINE) { end++; } end++; @@ -397,6 +409,7 @@ function getTrailingLineNode(context, node) { // Creates a zero-width "node" with a value to splice at that position. // WARNING: This is only safe to use when source maps are off! function getSpliceNodeAtPos(context, pos, loc, value) { + context.bytesAdded += Buffer.byteLength(value); return createNode({ start: pos, end: pos, diff --git a/packages/flow-remove-types/test/expected-pretty-inlinemap-stdin.js b/packages/flow-remove-types/test/expected-pretty-inlinemap-stdin.js index df3f0c3ca63..1e138b266f0 100644 --- a/packages/flow-remove-types/test/expected-pretty-inlinemap-stdin.js +++ b/packages/flow-remove-types/test/expected-pretty-inlinemap-stdin.js @@ -1,6 +1,10 @@ /* */ // @nolint +// multi-byte chars: +// Гарного дня, котики! 🐈 +var lambda = (α) => α; + // Regular import import { Something, @@ -131,4 +135,4 @@ var intersection; // Test generic async arrow funcion const f = async() => {}; -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIjxzdGRpbj4iXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkdBQUcsQUFBSzs7Ozs7O0VBTU4sQUFBQSxBQUFJLENBQUMsQUFBQSxBQUFRLEFBQUMsQUFBQTtFQUNkLEFBQUEsQUFBTSxDQUFDLEFBQUEsQUFBYyxBQUFBOzs7O0FBSXZCLEFBQTRDLEFBQUE7OztxQkFHdkIsQUFBTSxVQUFVLEFBQUEsQUFBQyxpQkFBaUIsQUFBQSxBQUFDLE9BQU8sQUFBQSxBQUFjLE9BQU8sQUFBUTs7aUJBRTNFLEFBQUs7Ozs7QUFJdEIsQUFJQyxBQUFBOzs7QUFHRCxBQUVDLEFBQUE7OztBQUdELEFBRUMsQUFBQTs7O3dCQUd1QixBQUFBLEFBQVUsT0FBTyxBQUFBLEFBQUcsQUFBQyxDQUFDLEFBQUEsQUFBVTs7UUFFaEQsQUFBUTs7O0VBR2QsQUFBQSxBQUFVLEFBQUE7O1VBRUYsQUFBTzs7Ozs7OzBCQU1TLEFBQUEsQUFBVSxDQUFDLEFBQUEsQUFBRztFQUN0QyxBQUFBLEFBQVUsQUFBQTs7VUFFRixBQUFPOzs7Ozs7YUFNSixBQUFHO09BQ1QsQUFBRzs7OztLQUlMLEFBQUcsRUFBRSxBQUFZOzs7Ozs7bUNBTWEsQUFBUTs7Ozs7QUFLM0MsQUFFQyxBQUFBOzs7QUFHRCxBQUFrQyxBQUFBOzs7QUFHbEMsQUFFQyxBQUFBOzs7QUFHRCxB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uLy8gVGVzdCBjb3ZhcmlhbnQgdHlwZSB2YXJpYW50IGNsYXNzIHdpdGggY29uc3RhaW50IGFuZCBkZWZhdWx0LlxuZXhwb3J0IGNsYXNzIFRlc3RDbGFzc1dpdGhEZWZhdWx0PCtUOiBUZXN0UmVhZE9ubHkgPSBUZXN0UmVhZE9ubHk+IHtcblxuICBjb25zdHJ1Y3RvcigpIHt9XG59XG5cbnZhciBuZXdsaW5lX2Fycm93ID0gKCk6XG5udW1iZXIgPT4gNDI7XG5cbnZhciBuZXdsaW5lX2Fycm93XzIgPSAoKSA6XG5udW1iZXI9PjQyO1xuXG4vLyBUZXN0IGNhbGxpbmcgYSBmdW5jdGlvbiB3aXRoIGV4cGxpY2l0IHR5cGUgYXJndW1lbnRzXG5kb1NvbWV0aGluZzxudW1iZXI+KDMpO1xuZG9Tb21ldGhpbmcgPFQsIFU+KDMpO1xuXG4vLyBUZXN0IGludm9raW5nIGEgY29uc3RydWN0b3Igd2l0aCBleHBsaWNpdCB0eXBlIGFyZ3VtZW50c1xubmV3IEV2ZW50PG51bWJlcj4oKTtcblxuLy8gVGVzdCB0eXBlIHVuaW9uIGFuZCBpbnRlcnNlY3Rpb24gc3ludGF4IHdpdGggbGVhZGluZyBcIm9wZXJhdG9yXCJcbnZhciB1bmlvbjogfCBUIHwgVTtcbnZhciBpbnRlcnNlY3Rpb246ICYgVCAmIFU7XG5cbi8vIFRlc3QgZ2VuZXJpYyBhc3luYyBhcnJvdyBmdW5jaW9uXG5jb25zdCBmID0gYXN5bmMgPFQ+KCk6IFQgPT4ge307XG4iXX0= diff --git a/packages/flow-remove-types/test/expected-pretty-inlinemap.js b/packages/flow-remove-types/test/expected-pretty-inlinemap.js index 3ececbc72be..1ee8181e512 100644 --- a/packages/flow-remove-types/test/expected-pretty-inlinemap.js +++ b/packages/flow-remove-types/test/expected-pretty-inlinemap.js @@ -1,6 +1,10 @@ /* */ // @nolint +// multi-byte chars: +// Гарного дня, котики! 🐈 +var lambda = (α) => α; + // Regular import import { Something, @@ -131,4 +135,4 @@ var intersection; // Test generic async arrow funcion const f = async() => {}; -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3Qvc291cmNlLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJHQUFHLEFBQUs7Ozs7OztFQU1OLEFBQUEsQUFBSSxDQUFDLEFBQUEsQUFBUSxBQUFDLEFBQUE7RUFDZCxBQUFBLEFBQU0sQ0FBQyxBQUFBLEFBQWMsQUFBQTs7OztBQUl2QixBQUE0QyxBQUFBOzs7cUJBR3ZCLEFBQU0sVUFBVSxBQUFBLEFBQUMsaUJBQWlCLEFBQUEsQUFBQyxPQUFPLEFBQUEsQUFBYyxPQUFPLEFBQVE7O2lCQUUzRSxBQUFLOzs7O0FBSXRCLEFBSUMsQUFBQTs7O0FBR0QsQUFFQyxBQUFBOzs7QUFHRCxBQUVDLEFBQUE7Ozt3QkFHdUIsQUFBQSxBQUFVLE9BQU8sQUFBQSxBQUFHLEFBQUMsQ0FBQyxBQUFBLEFBQVU7O1FBRWhELEFBQVE7OztFQUdkLEFBQUEsQUFBVSxBQUFBOztVQUVGLEFBQU87Ozs7OzswQkFNUyxBQUFBLEFBQVUsQ0FBQyxBQUFBLEFBQUc7RUFDdEMsQUFBQSxBQUFVLEFBQUE7O1VBRUYsQUFBTzs7Ozs7O2FBTUosQUFBRztPQUNULEFBQUc7Ozs7S0FJTCxBQUFHLEVBQUUsQUFBWTs7Ozs7O21DQU1hLEFBQVE7Ozs7O0FBSzNDLEFBRUMsQUFBQTs7O0FBR0QsQUFBa0MsQUFBQTs7O0FBR2xDLEFBRUMsQUFBQTs7O0FBR0QsQUFFQyxBQUFBOzs7QUFHRCxBQUdFLEFBQUE7OztBQUdGLEFBQStCLEFBQUE7OztBQUcvQixBQUFnQixBQUFBOzs7QUFHaEIsQUFBa0IsQUFBQTs7Ozs7O0FBTWxCLEFBQWtDLEFBQUE7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QTs7VUFFRixBQUFPOzs7Ozs7MEJBTVMsQUFBQSxBQUFVLENBQUMsQUFBQSxBQUFHO0VBQ3RDLEFBQUEsQUFBVSxBQUFBOztVQUVGLEFBQU87Ozs7OzthQU1KLEFBQUc7T0FDVCxBQUFHOzs7O0tBSUwsQUFBRyxFQUFFLEFBQVk7Ozs7OzttQ0FNYSxBQUFROzs7OztBQUszQyxBQUVDLEFBQUE7OztBQUdELEFBQWtDLEFBQUE7OztBQUdsQyxBQUVDLEFBQUE7OztBQUdELEFBRUMsQUFBQTs7O0FBR0QsQUFHRSxBQUFBOzs7QUFHRixBQUErQixBQUFBOzs7QUFHL0IsQUFBZ0IsQUFBQTs7O0FBR2hCLEFBQWtCLEFBQUE7Ozs7OztBQU1sQixBQUFrQyxBQUFBOzs7O2FBSXJCLEFBQU07Ozs7Ozs7QUFPbkIsQUFBZ0QsQUFBQTs7b0JBRTVCLEFBQUcsbUJBQW1CLEFBQUEsQUFBVSxDQUFDLEFBQUEsQUFBYTs7RUFFaEUsQUFBQSxBQUFRLEFBQUE7O21CQUVTLEFBQUc7Ozs7T0FJZixBQUFHOzs7Ozs7OzRCQU9rQixBQUFHLE1BQU0sQUFBRyxDQUFDLEFBQVk7Ozs7O0FBS3JELEFBRUcsQUFBQTs7O2lDQUc4QixBQUFpQzs7Ozs7c0JBSzVDLEFBQ2hCOzt5QkFFbUIsQUFBQSxBQUNuQjs7O1dBR0ssQUFBUTtZQUNQLEFBQUEsQUFBTTs7O1NBR1QsQUFBUTs7O1NBR1IsQUFBUztnQkFDRixBQUFTOzs7Z0JBR1QsQUFBQSxBQUFHLEVBQUUsQUFBRyJ9 diff --git a/packages/flow-remove-types/test/expected-pretty.js b/packages/flow-remove-types/test/expected-pretty.js index 03e91e644f9..4d862a115f9 100644 --- a/packages/flow-remove-types/test/expected-pretty.js +++ b/packages/flow-remove-types/test/expected-pretty.js @@ -1,6 +1,10 @@ /* */ // @nolint +// multi-byte chars: +// Гарного дня, котики! 🐈 +var lambda = (α) => α; + // Regular import import { Something, diff --git a/packages/flow-remove-types/test/expected-with-maps/test/source.js b/packages/flow-remove-types/test/expected-with-maps/test/source.js index ee2fa4e7dc4..aecb2372867 100644 --- a/packages/flow-remove-types/test/expected-with-maps/test/source.js +++ b/packages/flow-remove-types/test/expected-with-maps/test/source.js @@ -1,6 +1,10 @@ /* */ // @nolint +// multi-byte chars: +// Гарного дня, котики! 🐈 +var lambda = (α) => α; + // Regular import import { Something, diff --git a/packages/flow-remove-types/test/expected-with-maps/test/source.js.map b/packages/flow-remove-types/test/expected-with-maps/test/source.js.map index dd076d097f8..e0363288107 100644 --- a/packages/flow-remove-types/test/expected-with-maps/test/source.js.map +++ b/packages/flow-remove-types/test/expected-with-maps/test/source.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../source.js"],"names":[],"mappings":"GAAG,AAAK;;;;;;EAMN,AAAA,AAAI,CAAC,AAAA,AAAQ,AAAC,AAAA;EACd,AAAA,AAAM,CAAC,AAAA,AAAc,AAAA;;;;AAIvB,AAA4C,AAAA;;;qBAGvB,AAAM,UAAU,AAAA,AAAC,iBAAiB,AAAA,AAAC,OAAO,AAAA,AAAc,OAAO,AAAQ;;iBAE3E,AAAK;;;;AAItB,AAIC,AAAA;;;AAGD,AAEC,AAAA;;;AAGD,AAEC,AAAA;;;wBAGuB,AAAA,AAAU,OAAO,AAAA,AAAG,AAAC,CAAC,AAAA,AAAU;;QAEhD,AAAQ;;;EAGd,AAAA,AAAU,AAAA;;UAEF,AAAO;;;;;;0BAMS,AAAA,AAAU,CAAC,AAAA,AAAG;EACtC,AAAA,AAAU,AAAA;;UAEF,AAAO;;;;;;aAMJ,AAAG;OACT,AAAG;;;;KAIL,AAAG,EAAE,AAAY;;;;;;mCAMa,AAAQ;;;;;AAK3C,AAEC,AAAA;;;AAGD,AAAkC,AAAA;;;AAGlC,AAEC,AAAA;;;AAGD,AAEC,AAAA;;;AAGD,AAGE,AAAA;;;AAGF,AAA+B,AAAA;;;AAG/B,A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B,AAAA;;;AAG/B,AAAgB,AAAA;;;AAGhB,AAAkB,AAAA;;;;;;AAMlB,AAAkC,AAAA;;;;aAIrB,AAAM;;;;;;;AAOnB,AAAgD,AAAA;;oBAE5B,AAAG,mBAAmB,AAAA,AAAU,CAAC,AAAA,AAAa;;EAEhE,AAAA,AAAQ,AAAA;;mBAES,AAAG;;;;OAIf,AAAG;;;;;;;4BAOkB,AAAG,MAAM,AAAG,CAAC,AAAY;;;;;AAKrD,AAEG,AAAA;;;iCAG8B,AAAiC;;;;;sBAK5C,AAChB;;yBAEmB,AAAA,AACnB;;;WAGK,AAAQ;YACP,AAAA,AAAM;;;SAGT,AAAQ;;;SAGR,AAAS;gBACF,AAAS;;;gBAGT,AAAA,AAAG,EAAE,AAAG"} diff --git a/packages/flow-remove-types/test/expected.js b/packages/flow-remove-types/test/expected.js index 274d6ab848c..909239e41d5 100644 --- a/packages/flow-remove-types/test/expected.js +++ b/packages/flow-remove-types/test/expected.js @@ -1,6 +1,10 @@ /* */ // @nolint +// multi-byte chars: +// Гарного дня, котики! 🐈 +var lambda = (α ) => α; + // Regular import import { Something, diff --git a/packages/flow-remove-types/test/source.js b/packages/flow-remove-types/test/source.js index 10fe47b13ba..44ee839d571 100644 --- a/packages/flow-remove-types/test/source.js +++ b/packages/flow-remove-types/test/source.js @@ -1,6 +1,10 @@ /* @flow */ // @nolint +// multi-byte chars: +// Гарного дня, котики! 🐈 +var lambda: λ = (α: number): number => α; + // Regular import import { Something,