0.1.0 • Published 2 years ago
cookie-observer v0.1.0
CookieObserver
| 한국어 |
|---|
Provides an observer-style implementation for document.cookie and cookieStore, along with a polyfill class for cookieStore for unsupported browsers.
Installation
# npm
npm install cookie-observer
# yarn
yarn add cookie-observer
# pnpm
pnpm add cookie-observerUsage
import { CookieStore, CookieObserver } from 'cookie-observer';
const store =
typeof cookieStore !== 'undefined' ? cookieStore : new CookieStore(document);
const observer = new CookieObserver((entries) => {
console.debug(entries);
});
observer.observe(store);Limitations
Access to cookies at the JavaScript level is limited to the name and value of the cookie.
To maintain compatibility and consistency, the fields other than name and value have intentionally been omitted.
TODO
- Implement the
cookieStoreinterface. - Add the
observeoption (adjust interval, maintain extra fields, etc.). - Add a polyfill like installation script.
0.1.0
2 years ago