MCPcopy Create free account
hub / github.com/nodejs/node / copyStandardPrologue

Function copyStandardPrologue

test/fixtures/snapshot/typescript.js:27017–27039  ·  view source on GitHub ↗

* Copies only the standard (string-expression) prologue-directives into the target statement-array. * @param source origin statements array * @param target result statements array * @param statementOffset The offset at which to begin the copy. * @param ensureUseSt

(source, target, statementOffset, ensureUseStrict)

Source from the content-addressed store, hash-verified

27015 * @returns Count of how many directive statements were copied.
27016 */
27017 function copyStandardPrologue(source, target, statementOffset, ensureUseStrict) {
27018 if (statementOffset === void 0) { statementOffset = 0; }
27019 ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array");
27020 var foundUseStrict = false;
27021 var numStatements = source.length;
27022 while (statementOffset < numStatements) {
27023 var statement = source[statementOffset];
27024 if (ts.isPrologueDirective(statement)) {
27025 if (isUseStrictPrologue(statement)) {
27026 foundUseStrict = true;
27027 }
27028 target.push(statement);
27029 }
27030 else {
27031 break;
27032 }
27033 statementOffset++;
27034 }
27035 if (ensureUseStrict && !foundUseStrict) {
27036 target.push(createUseStrictPrologue());
27037 }
27038 return statementOffset;
27039 }
27040 function copyCustomPrologue(source, target, statementOffset, visitor, filter) {
27041 if (filter === void 0) { filter = ts.returnTrue; }
27042 var numStatements = source.length;

Callers 1

copyPrologueFunction · 0.85

Calls 4

isUseStrictPrologueFunction · 0.85
createUseStrictPrologueFunction · 0.85
assertMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected