Skip to content

Instantly share code, notes, and snippets.

View xiaoliang2233's full-sized avatar

Xiaoliang Wang xiaoliang2233

View GitHub Profile
@xiaoliang2233
xiaoliang2233 / Timer.js
Last active July 7, 2021 10:53
debounceTime, auditTime, throttleTime
/**
* auditTime 是每次点击开始计时, 超时的时候再emit最近的一次事件
*
* throttleTime 是每次点击emit事件, 之后的一段时间不会再触发事件
*
* debounceTime 是每次点击重新计时, 超时的时候emit此事件
*/
let print = auditTime(1000, e => {
console.log('😋', e)
@xiaoliang2233
xiaoliang2233 / event-bus.js
Created August 7, 2017 06:18
vue event bus , add once and off methods
import Vue from "vue"
import * as constants from "./event-constant"
const eventMap = new Map()
const eventBus = {
data() {
return {
eventMap,
registerEvent: {
@xiaoliang2233
xiaoliang2233 / event-bus.js
Last active August 6, 2017 05:21
event bus for vue
import Vue from "vue"
import * as constants from "./event-constant"
const eventMap = new Map()
const eventBus = {
data() {
return {
eventMap,
registerEvent: {
function getCookie(name) {
let cookies = document.cookie.split(';');
let cookiesObj = {};
cookies.forEach(c => {
if (!c) {
return;
}
let cs = c.trim().split('=');
if (cs.length < 2) {
return;