Last active
July 22, 2019 23:02
-
-
Save mrcnc/4af359833af45447eef4d40512239ef0 to your computer and use it in GitHub Desktop.
turn browser cookies into an array of key/value pairs (in a functional style)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie | |
document.cookie.split(';') | |
.map(s => s.split('=')) | |
.filter(a => a[0] && a[1]) | |
// if there is a shorter, code golf way to do this, let me know | |
.reduce((acc, a) => { let obj = {}; obj[a[0].trim()] = a[1]; acc.push(obj); return acc }, []) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.