@zaxjs/cookie
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

Zax Cookie

NPM version Build Status codecov code style: prettier

Cookie module

Browsers support

IE / EdgeIE / Edge FirefoxFirefox ChromeChrome SafariSafari iOS SafariiOS Safari OperaOpera
IE8+ Edge+ last 10 versions last 10 versions last 2 versions last 2 versions last 2 versions

Install

npm i @zaxjs/cookie -S

build with rollup

npm run build 

use

import zaxCookie, { getDomain, setCookie, getCookie, delCookie, clearCookie } from '@zaxjs/cookie'

. getDomain

zaxCookie.getDomain() //=> getDomain()
localhost

. set

zaxCookie.set('token', 'abc') //=> setCookie('token', 'abc')
zaxCookie.set('token', 'abc', 1)
zaxCookie.set('token', 'abc', {
    path: '/',
    domain: 'demo.com'
    expires: new Date(Date.now() + 1 * 864e5),
    sameSite: 'lax'
})
token=abc; path=/; domain=localhost
token=abc; path=/; domain=localhost; expires=Wed, 20 Nov 2019 09:18:38 GMT
token=abc; path=/; domain=demo.com; expires=Wed, 20 Nov 2019 09:18:38 GMT; sameSite=lax

. get

zaxCookie.get('token') //=> getCookie('token')
abc

. del

zaxCookie.del('token') //=> delCookie('token')
zaxCookie.del('token', {
    path: '/',
    domain: 'demo.com'
})

. clear

zaxCookie.clear() //=> clearCookie()

More

Package Sidebar

Install

npm i @zaxjs/cookie

Weekly Downloads

0

Version

0.0.3

License

MIT

Unpacked Size

42.4 kB

Total Files

30

Last publish

Collaborators

  • jsonchou