/
TimurIsm
/
OpenEyes
Обзор
Документация
Войти
/
TimurIsm
/
OpenEyes
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
back/utils/stringUtils.js
30 строк
850 B
TimurIsm
first_commit
16 май 2026, 15:34
16 май 2026, 15:34
4d3f198
Код
Авторство
О чём код?
const deepTrim = (str) => { if (!str || typeof str !== 'string') return ''; let cleaned = str .replace(/[\u200B-\u200D\uFEFF]/g, '') .replace(/[\u3164\u115F\u1160\u180E\u200E\u200F\u2028\u2029]/g, '') .replace(/[\u00A0\u2007\u202F\u2060]/g, ' '); return cleaned.trim(); }; const isEmptyOrInvisible = (str) => { if (!str || typeof str !== 'string') return true; return deepTrim(str).length === 0; }; const cleanArray = (arr) => { if (!Array.isArray(arr)) return []; return arr.map(item => { if (typeof item === 'string') return deepTrim(item); if (item && typeof item === 'object' && item.text) { return { ...item, text: deepTrim(item.text) }; } return item; }); }; module.exports = { deepTrim, isEmptyOrInvisible, cleanArray };