Skip to content

Instantly share code, notes, and snippets.

View tongyifan's full-sized avatar
🕊️
Feel free to contact me

Yifan Tong tongyifan

🕊️
Feel free to contact me
  • Alibaba
  • Hangzhou, China
View GitHub Profile
@tongyifan
tongyifan / parsecookie.js
Created February 6, 2020 04:00 — forked from rendro/parsecookie.js
Parse document.cookie into object
document.cookie.split(';').map(function(c) {
return c.trim().split('=').map(decodeURIComponent);
}).reduce(function(a, b) {
try {
a[b[0]] = JSON.parse(b[1]);
} catch (e) {
a[b[0]] = b[1];
}
return a;
}, {});