Skip to content

Instantly share code, notes, and snippets.

@plugn
Last active February 1, 2019 13:43
Show Gist options
  • Save plugn/e4053a02883ed602b206acc085c7e8d2 to your computer and use it in GitHub Desktop.
Save plugn/e4053a02883ed602b206acc085c7e8d2 to your computer and use it in GitHub Desktop.
getting cookies utility
/**
* @author Max L Dolgov
* @description getting cookies utility
*/
export const getCookies = () => document.cookie.split(';').map(s => s.trim().split('='))
export const getCookie = cookieName => (getCookies().find(v => v[0] === cookieName) || [])[1]
export const getCookiesMap = () => getCookies().reduce(reducer = (acc, v) => ({ ...acc, [v[0]]: v[1] }), {})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment