2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-23 11:40:51 +08:00
xiaoyao-cvs-plugin/model/mys/utils.js

30 lines
541 B
JavaScript
Raw Normal View History

2022-07-29 01:42:35 +08:00
import _ from 'lodash';
export async function sleepAsync(sleepms) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, sleepms)
});
}
export async function randomSleepAsync(){
let sleep = 2 * 1000 + _.random(3 * 1000);
await sleepAsync(sleep);
}
export function randomString(length){
let randomStr = '';
for (let i = 0; i < length; i++) {
randomStr += _.sample('abcdefghijklmnopqrstuvwxyz0123456789');
}
return randomStr;
}
export default {
sleepAsync,
randomSleepAsync,
randomString
}