UNPKG

stylelint-css-in-js-syntax

Version:

This plugin provides [ESLint](https://eslint.org/) rules that limit the line length of your comments. Furthermore, an **automatic fix** is included such that you can save time manually formatting your comments. As such it is recommended to apply this rule

22 lines (20 loc) 612 B
const WHITESPACE_CHARS = [" ", "\n", " ", "\r"]; function getPreviousWord(str, currentIndex) { const prevWordChars = []; let hasEncounteredText = false; for (let i = currentIndex - 1; i >= 0; i--) { const currentChar = str[i]; if (!currentChar || WHITESPACE_CHARS.includes(currentChar)) { if (hasEncounteredText) { return prevWordChars.join(""); } else { continue; } } hasEncounteredText = true; prevWordChars.unshift(currentChar); } return prevWordChars.join(""); } export { getPreviousWord }; //# sourceMappingURL=util.get-previous-word.mjs.map