mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-09-24 13:03:30 +08:00
拆分数据处理分类,新增编码加密、数学计算分类
This commit is contained in:
5
plugin/lib/quickcomposer/math/index.js
Normal file
5
plugin/lib/quickcomposer/math/index.js
Normal file
@@ -0,0 +1,5 @@
|
||||
const random = require("./random");
|
||||
|
||||
module.exports = {
|
||||
random,
|
||||
};
|
23
plugin/lib/quickcomposer/math/random.js
Normal file
23
plugin/lib/quickcomposer/math/random.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const randomInt = (start, end) => {
|
||||
return Math.round(Math.random() * (end - start) + start);
|
||||
};
|
||||
|
||||
const random = (isInt = false, start, end) => {
|
||||
if (!start && !end) {
|
||||
return isInt ? randomInt(0, 1000000) : Math.random();
|
||||
}
|
||||
|
||||
if (!end) {
|
||||
end = Math.abs(randomInt(0, 1000000) - start);
|
||||
}
|
||||
|
||||
if (!start) {
|
||||
start = 0;
|
||||
}
|
||||
|
||||
// 有start和end:返回区间随机数
|
||||
const random = Math.random() * (end - start) + start;
|
||||
return isInt ? Math.round(random) : random;
|
||||
};
|
||||
|
||||
module.exports = random;
|
Reference in New Issue
Block a user