feat: add random to (#35)

* feat: add random to

* add actions

* up

* up version

* add less
This commit is contained in:
xrkffgg
2021-01-11 21:32:00 +08:00
committed by GitHub
parent 3836013160
commit 8e05706e43
20 changed files with 1768 additions and 158 deletions

View File

@@ -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,