This file contains hidden or 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
const nativeMax = Math.max; | |
const nativeMin = Math.min; | |
function debounce(func, wait, options) { | |
let lastArgs, | |
lastThis, | |
maxWait, | |
result, | |
timerId, | |
lastCallTime, | |
lastInvokeTime = 0, |
This file contains hidden or 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
function debounce(fn, wait, leading = false) { | |
let timerId, | |
lastInvokeTime = 0, | |
context, | |
args; | |
const execute = function () { | |
fn.apply(context, args); | |
lastInvokeTime = Date.now(); | |
}; |
This file contains hidden or 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
function tokenize(code) { | |
const tokens = []; | |
const length = code.length; | |
let char; | |
for (let i = 0; i < length; i++) { | |
char = code.charAt(i); | |
if (/;/.test(char)) { | |
const token = { |
This file contains hidden or 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
/** | |
*if (1 > 0) { | |
alert('1 > 0'); | |
} | |
* | |
* @param {*} params | |
*/ | |
function parser(tokens) { | |
let i = -1; |