This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class Ticker { | |
static RAF: any = null | |
static CAF: any = null | |
static prefixs = ['webkit', 'moz', 'o', 'ms'] | |
constructor() { | |
Ticker.RAF = this.getRequestAnimationFrame() | |
Ticker.CAF = this.getCancelAnimationFrame() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Display all issue's detail in one page by iframe | |
* tips: | |
* 1. Disalbe 'x-frame-options' by chrome extension, you can install https://chrome.google.com/webstore/detail/ignore-x-frame-headers/gleekbfjekiniecknbkamfmkohkpodhe | |
* 2. Compress below code to one line by Javscript online Compressor, you can use https://jscompress.com/ | |
* 3. Copy the compressed code and paste to chrome address bar then save as a bookmark | |
* 4. Open the issue list page then click that bookmark | |
* 5 .If you want to cancel display, retry step 4 again | |
*/ | |
javascript: (function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scripts": [], | |
"showConsole": true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class Polling { | |
private timer: number | |
private interval: number | |
private times: number | |
constructor(interval = 5e3, times = -1) { | |
this.interval = interval | |
this.times = times |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
/** | |
* 手写 new 操作符 | |
* 注:暂不支持 Class 传入 | |
* @param {*} fn 函数 | |
* @param {...any} args 其它参数 | |
* @returns function | |
*/ | |
function _new(fn, ...args) { | |
// 创建拥有 fn 原型的对象 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
/** | |
* 手写实现 Promise.all 方法 | |
* @param {string|array} values 一个可迭代对象 | |
* @returns promise | |
*/ | |
Promise._all = (values) => { | |
// 判断是否为可迭代对象 | |
if (!values.hasOwnProperty('length')) { | |
throw new Error(`TypeError: ${typeof values} is not iterable`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const astObj = { | |
tag: 'DIV', | |
attrs: { | |
id: 'app' | |
}, | |
children: [ | |
{ | |
tag: 'SPAN', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
/** | |
* 使用 setTimeout 模拟 setInterval | |
* @param {Function|string} handler 要执行的函数或者要执行的函数字符串 | |
* @param {number} delay 时间间隔 | |
*/ | |
window._setInterval = function (handler, delay) { | |
// 判断第二个参数是否为字符串 | |
const isFunc = typeof handler === 'string' | |
// 获取第二个参数后的其它参数 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
/** | |
* 手写 apply 方法 | |
* @param {*} context 上下文 this | |
* @returns 指定的 this 值和参数 | |
*/ | |
Function.prototype._apply = function (context) { | |
// 判断上下文 context 是否存在 | |
// 不存在则指向 window |
NewerOlder