kahnvex / cookie-monster Goto Github PK
View Code? Open in Web Editor NEWNO LONGER MAINTAINED
Home Page: https://www.npmjs.org/package/cookie-monster
License: MIT License
NO LONGER MAINTAINED
Home Page: https://www.npmjs.org/package/cookie-monster
License: MIT License
I'm still using the old version of Cookie monster in some of my projects but the version 0.2.1 is fairly outdated and non-maintained. I'd like to refactor it in a proper ES6 format and bundle it into different formats using Rollup. If you give me an ok, I'll prepare the pull request for version 1.0. Additionally, I'm also interested in maintaining the package since, well, I'm using it already and had contributed to it in the past.
Change proposal:
.get()
, .set()
and .remove()
methods.key(n)
method and .length
property to completely conform to localStorage API.getItem()
and .removeItem()
Nothing is exported in node.js as document is undefined.
if (typeof document !== 'undefined') module.exports = exports = bake(document);
Cookies are the old-school way to store data client side. local storage and session storage, both conforming to the Storage API, are now the recommended way to store client-only data (in general).
Cookies and local/session stores all function fundamentally the same way: as key/value stores. Of course, cookies have additional properties (path
, domain
, secure
, etc), but that's really just metadata on the key/value pair.
I would like to propose that the cookie-monster API conform to the Storage API such that switching between stores is trivial.
As the current API is only get
and set
, a first step could be to alias getItem
to get
and setItem
to set
. Following that, removeItem
and clear
methods could be added for safe removal of single items and the entire cookie string, respectively. And finally, for completeness, key
and length
could be added (though they are clearly low on the priority list).
I don't see any backwards compatibility issues if getItem
and setItem
are aliased to the current methods. Of course, if it's desired to actually deprecate get
/set
then it would be beneficial to have them aliased for a while with warning messages, and then remove the get
/set
variants in a major version bump.
More than happy to submit a couple PRs if this sounds like something that might be acceptable.
It would be more beneficial to add the secure
param based on a boolean value rather than the mere existence of the property.
E.g.
if (opts.hasOwnProperty('secure') && opts.secure === true) newCookie += '; secure';
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.