Skip to content

Instantly share code, notes, and snippets.

@jasonsperske
Last active May 20, 2022 17:49
Show Gist options
  • Save jasonsperske/d18db7a84fa7904a65cfab492978c530 to your computer and use it in GitHub Desktop.
Save jasonsperske/d18db7a84fa7904a65cfab492978c530 to your computer and use it in GitHub Desktop.
A super tiny function that converts the document.cookie to an object
function cookieMap() {
return document.cookie
.split('; ')
.map((c) => Object.fromEntries([c.split(/=(.*)/s).slice(0, 2)]))
.reduce((a, v) => ({ ...a, ...v }), {});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment