Skip to content

Instantly share code, notes, and snippets.

Avatar
😀

Yawenina Yawenina

😀
View GitHub Profile
View parser.js
/**
*if (1 > 0) {
alert('1 > 0');
}
*
* @param {*} params
*/
function parser(tokens) {
let i = -1;
@Yawenina
Yawenina / tokenize.js
Created Nov 12, 2019
tokenize js code
View tokenize.js
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 = {
@Yawenina
Yawenina / debounce-throttle-trial.js
Last active Jul 15, 2017
simple debounce and throttle
View debounce-throttle-trial.js
function debounce(fn, wait, leading = false) {
let timerId,
lastInvokeTime = 0,
context,
args;
const execute = function () {
fn.apply(context, args);
lastInvokeTime = Date.now();
};
@Yawenina
Yawenina / debounce-lodash.js
Last active Sep 21, 2021
lodash debounce and throttle source code
View debounce-lodash.js
const nativeMax = Math.max;
const nativeMin = Math.min;
function debounce(func, wait, options) {
let lastArgs,
lastThis,
maxWait,
result,
timerId,
lastCallTime,
lastInvokeTime = 0,