Sha256: 113b24ecfeef2bdfd7371756895aa439a30ad60fd5bbd6779871eff583ac9bf0

Contents?: true

Size: 902 Bytes

Versions: 4

Compression:

Stored size: 902 Bytes

Contents

// TODO this function is slightly flawed – it works on the original string,
// not its current edited state.
// That's not a problem for the way that it's currently used, but it could
// be in future...
export default function deindent(node, code) {
	const start = node.start;
	const end = node.end;

	const indentStr = code.getIndentString();
	const indentStrLen = indentStr.length;
	const indentStart = start - indentStrLen;

	if (
		!node.program.indentExclusions[indentStart] &&
		code.original.slice(indentStart, start) === indentStr
	) {
		code.remove(indentStart, start);
	}

	const pattern = new RegExp(indentStr + '\\S', 'g');
	const slice = code.original.slice(start, end);
	let match;

	while ((match = pattern.exec(slice))) {
		const removeStart = start + match.index;
		if (!node.program.indentExclusions[removeStart]) {
			code.remove(removeStart, removeStart + indentStrLen);
		}
	}
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jass-0.9.5 vendor/node_modules/buble/src/utils/deindent.js
jass-0.9.4 vendor/node_modules/buble/src/utils/deindent.js
jass-0.9.3 vendor/node_modules/buble/src/utils/deindent.js
jass-0.9.1 vendor/node_modules/buble/src/utils/deindent.js