string-detect-indent
Version:
simple detect string indent
26 lines (21 loc) • 993 B
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.StringDetectIndent = {}));
})(this, (function (exports) { 'use strict';
const REGEX_MATCH_INDENT = /^([ \t]*)((?:[\S\r\n].*|)$)/;
const REGEX_MATCH_INDENT_NO_BREAK_SPACE = /^([ \t\xa0]*)((?:[\S\r\n].*|)$)/;
function detectIndentLine(input, options) {
const m = (options !== null && options !== void 0 && options.includeNoBreakSpace ? REGEX_MATCH_INDENT_NO_BREAK_SPACE : REGEX_MATCH_INDENT).exec(input);
return {
input,
indent: m[1],
body: m[2],
bool: m[1].length > 0
};
}
exports.default = detectIndentLine;
exports.detectIndentLine = detectIndentLine;
Object.defineProperty(exports, '__esModule', { value: true });
}));
//# sourceMappingURL=index.umd.development.cjs.map