style: format

This commit is contained in:
元凛
2022-02-10 17:55:52 +08:00
parent bdb9ee8890
commit c626dd5ef0
13 changed files with 218 additions and 126 deletions

View File

@@ -7,25 +7,29 @@ export const dealRandomAssignees = (assignees: string, randomTo: string | void):
arr = sampleSize(arr, Number(randomTo));
}
return arr;
}
};
export const matchKeyword = (content: string, keywords: string[]): boolean => {
return !!keywords.find(item => content.toLowerCase().includes(item));
}
};
export const checkDuplicate = (body: string | void): boolean => {
if (!body || !body.startsWith('Duplicate of')) {
return false;
}
const arr = body.split(' ');
return arr[0] == 'Duplicate' && arr[1] == 'of'
}
return arr[0] == 'Duplicate' && arr[1] == 'of';
};
export const getPreMonth = (m: number): number => {
return m == 1 ? 12 : m - 1;
}
};
// replace some & split & cull empty
export const replaceStr2Arr = (str: string, replace: string, split: string): string[] => {
return str.replace(replace, '').trim().split(split).reduce((result: string[], it) => it ? [...result, it.trim()] : result, []);
}
return str
.replace(replace, '')
.trim()
.split(split)
.reduce((result: string[], it) => (it ? [...result, it.trim()] : result), []);
};