bpms_site/.svn/pristine/9a/9a6b5dcbcdb9afbac4bc4a86bdc039d88fc75698.svn-base
2025-11-02 16:38:49 +03:30

46 lines
1.5 KiB
Plaintext

// Returns true if the given character is a whitespace character, false otherwise.
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getWordsAndWhitespaces", {
enumerable: true,
get: function() {
return getWordsAndWhitespaces;
}
});
function isWhitespace(char) {
return char === " " || char === "\n" || char === " " || char === "\r";
}
function getWordsAndWhitespaces(text) {
const wordsAndWhitespaces = [];
let current = "";
let currentIsWhitespace = false;
for (const char of text){
if (current.length === 0) {
current += char;
currentIsWhitespace = isWhitespace(char);
continue;
}
const nextIsWhitespace = isWhitespace(char);
if (currentIsWhitespace === nextIsWhitespace) {
current += char;
} else {
wordsAndWhitespaces.push(current);
current = char;
currentIsWhitespace = nextIsWhitespace;
}
}
if (current.length > 0) {
wordsAndWhitespaces.push(current);
}
return wordsAndWhitespaces;
}
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=get-words-and-whitespaces.js.map