Skip to content

Instantly share code, notes, and snippets.

@jasonsperske
Last active May 20, 2022 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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