js-cookie v3.0.0-beta.1 Release Notes
Release Date: 2019-12-11 // over 4 years ago-
โ Removed
defaults
in favor of a builder: now to supply an api instance with particular predefined (cookie) attributes there'sCookies.withAttributes()
, e.g.:const api = Cookies.withAttributes({ path: '/', secure: true})api.set('key', 'value') // writes cookie with path: '/' and secure: true...
๐ง The attributes that an api instance is configured with are exposed as
attributes
property; it's an immutable object and unlikedefaults
cannot be changed to configure the api.๐ The mechanism to fall back to the standard, internal converter by returning a falsy value in a custom read converter has been removed. Instead the default converters are now exposed as
Cookies.converter
, which allows for implementing self-contained custom converters providing the same behavior:const customReadConverter = (value, name) => { if (name === 'special') { return unescape(value) } return Cookies.converter.read(value) }
withConverter()
no longer accepts a function as argument to be turned into a read converter. It is now required to always pass an object with the explicit type(s) of converter(s):const api = Cookies.withConverter({ read: (value, name) => unescape(value) })
๐ง The converter(s) that an api instance is configured with are exposed as
converter
property; it's an immutable object and cannot be changed to configure the api.The entire api instance is now immutable.