
package.schematics.bundles.leading_space-d190b83b.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core Show documentation
Show all versions of core Show documentation
Angular - the core framework
'use strict';
/**
* @license Angular v19.0.5
* (c) 2010-2024 Google LLC. https://angular.io/
* License: MIT
*/
'use strict';
/**
* Gets the leading line whitespace of a given node.
*
* Useful for inserting e.g. TODOs without breaking indentation.
*/
function getLeadingLineWhitespaceOfNode(node) {
const fullText = node.getFullText().substring(0, node.getStart() - node.getFullStart());
let result = '';
for (let i = fullText.length - 1; i > -1; i--) {
// Note: LF line endings are `\n` while CRLF are `\r\n`. This logic should cover both, because
// we start from the beginning of the node and go backwards so will always hit `\n` first.
if (fullText[i] !== '\n') {
result = fullText[i] + result;
}
else {
break;
}
}
return result;
}
exports.getLeadingLineWhitespaceOfNode = getLeadingLineWhitespaceOfNode;
© 2015 - 2025 Weber Informatics LLC | Privacy Policy