Skip to content

Instantly share code, notes, and snippets.

View YakovlevEugen's full-sized avatar
🎯

Yakovlev Eugen YakovlevEugen

🎯
View GitHub Profile
@YakovlevEugen
YakovlevEugen / .js
Created August 20, 2025 09:34
Truncate a string with ellipsis
/**
* Truncate a string with ellipsis
* @param {string} str - Original string
* @param {number} maxLength - Maximum length of the resulting string including ellipsis
* @param {'middle'|'end'} [mode='middle'] - Truncation mode: 'middle' or 'end'
* @returns {string} - Truncated string with ellipsis
*/
export const truncateString = (str, maxLength, mode = 'middle') => {
if (str.length <= maxLength || maxLength <= 3) return str;
if (mode === 'end') return str.slice(0, maxLength - 1) + '…';
@YakovlevEugen
YakovlevEugen / difference.js
Created October 19, 2021 14:03 — forked from Yimiprod/difference.js
Deep diff between two object, using lodash
/**
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {
return _.transform(object, function(result, value, key) {
if (!_.isEqual(value, base[key])) {
git branch | grep -v "master\|develop" | xargs git branch -D
Алиас для удаления:
alias gbDA="git branch | grep -v 'master\|develop' | xargs git branch -D"
git alias для удаления:
git config --global alias.clean-branches "!git branch | grep -v 'master\|develop' | xargs git branch -D"
Исключить ветки из удаления:
"master\|develop\|current_branch"