UNPKG

aws-sdk-js-codemod

Version:

Collection of codemod scripts that help update AWS SDK for JavaScript APIs

27 lines (26 loc) 866 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getMostUsedIndentationType = exports.IndentationType = void 0; const node_os_1 = require("node:os"); var IndentationType; (function (IndentationType) { IndentationType["TAB"] = "tab"; IndentationType["SPACE"] = "space"; })(IndentationType || (exports.IndentationType = IndentationType = {})); const getMostUsedIndentationType = (source) => { let tabCount = 0; let spaceCount = 0; for (const line of source.split(node_os_1.EOL)) { if (line.startsWith(" ")) { spaceCount++; } else if (line.startsWith("\t")) { tabCount++; } } if (tabCount > spaceCount) { return IndentationType.TAB; } return IndentationType.SPACE; }; exports.getMostUsedIndentationType = getMostUsedIndentationType;