mirror of
https://gitea.com/Lydanne/issues-helper.git
synced 2025-08-22 03:35:44 +08:00
feat: add random to (#35)
* feat: add random to * add actions * up * up version * add less
This commit is contained in:
15
src/util.js
15
src/util.js
@@ -1,4 +1,6 @@
|
||||
function dealInput (para) {
|
||||
const sampleSize = require('lodash/sampleSize');
|
||||
|
||||
function dealStringToArr (para) {
|
||||
/**
|
||||
* in 'x1,x2,x3'
|
||||
* out ['x1','x2','x3']
|
||||
@@ -15,6 +17,14 @@ function dealInput (para) {
|
||||
return arr;
|
||||
};
|
||||
|
||||
function dealRandomAssignees (assignees, randomTo) {
|
||||
let arr = dealStringToArr(assignees);
|
||||
if (randomTo && Number(randomTo) > 0 && Number(randomTo) < arr.length) {
|
||||
arr = sampleSize(arr, randomTo);
|
||||
}
|
||||
return arr;
|
||||
};
|
||||
|
||||
function matchKeyword (content, keywords) {
|
||||
return keywords.find(item => content.toLowerCase().includes(item));
|
||||
};
|
||||
@@ -37,7 +47,8 @@ function getPreMonth (m) {
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
dealInput,
|
||||
dealStringToArr,
|
||||
dealRandomAssignees,
|
||||
getPreMonth,
|
||||
matchKeyword,
|
||||
testDuplicate,
|
||||
|
Reference in New Issue
Block a user