@springernature/global-javascript
Advanced tools
Comparing version 2.3.1 to 2.4.0
# History | ||
## 2.4.0 (2020-08-24) | ||
* FEATURE: setCookie util | ||
* FEATURE: deleteCookie util | ||
## 2.3.1 (2020-08-20) | ||
@@ -4,0 +8,0 @@ * BUG: Fix checkConsent util - Adds safety check for cookie existence |
{ | ||
"name": "@springernature/global-javascript", | ||
"version": "2.3.1", | ||
"version": "2.4.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Globally shared Javascript helpers", |
@@ -21,2 +21,4 @@ # Global Javascript | ||
- [getCookie](#getcookie) | ||
- [setCookie](#setcookie) | ||
- [deleteCookie](#deletecookie) | ||
- [debounce](#debounce) | ||
@@ -79,2 +81,35 @@ - [throttle](#throttle) | ||
#### setCookie | ||
Sets a cookie with a name, value and attributes using `document.cookie`. | ||
Configurable options are: | ||
- `path` (string) | ||
- `domain` (string) | ||
- `max-age` (number as string) | ||
- `expires` (string) | ||
- `secure` (string) | ||
- `samesite` (string) | ||
```javascript | ||
setCookie('name-of-cookie', 'cookie-value', { | ||
path: '/', | ||
domain: 'mydomain.com', | ||
'max-age': '31536000' | ||
}); | ||
``` | ||
#### deleteCookie | ||
Expires a cookie by name from `document.cookie`. | ||
Configurable options are: | ||
- `path` (string) | ||
- `domain` (string) | ||
```javascript | ||
deleteCookie('name-of-cookie', { | ||
path: '/', | ||
domain: 'mydomain.com', | ||
}); | ||
``` | ||
#### debounce | ||
@@ -81,0 +116,0 @@ Allows sequential calls to a function to be grouped together so that the function will only be called once. |
@@ -7,2 +7,4 @@ // Util | ||
import {getCookie} from './util/get-cookie'; | ||
import {setCookie} from './util/set-cookie'; | ||
import {deleteCookie} from './util/delete-cookie'; | ||
import {checkConsent, isConsentBannerClosed} from './util/onetrust'; | ||
@@ -13,2 +15,2 @@ | ||
export {makeArray, createEvent, debounce, throttle, getCookie, getDataOptions, checkConsent, isConsentBannerClosed}; | ||
export {makeArray, createEvent, debounce, throttle, getCookie, setCookie, deleteCookie, getDataOptions, checkConsent, isConsentBannerClosed}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24067
22
507
214