@cedx/cookies
Advanced tools
Comparing version 5.0.1 to 5.1.0
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -44,6 +44,7 @@ /** | ||
* Gets the deserialized value associated with the specified key. | ||
* @template T | ||
* @param {string} key The cookie name. | ||
* @returns {any} The cookie value, or `null` if the key does not exist or the value cannot be deserialized. | ||
* @returns {T|null} The cookie value, or `null` if the key does not exist or the value cannot be deserialized. | ||
*/ | ||
getObject(key: string): any; | ||
getObject<T>(key: string): T | null; | ||
/** | ||
@@ -70,8 +71,9 @@ * Gets a value indicating whether this cookie store contains the specified key. | ||
* Looks up the deserialized value of the specified key, or add a new serialized value if it isn't there. | ||
* @template T | ||
* @param {string} key The cookie name. | ||
* @param {() => unknown} ifAbsent A function producing the new cookie value. | ||
* @param {() => T} ifAbsent A function producing the new cookie value. | ||
* @param {import("./cookie_options.js").CookieOptionsParams} [options] The cookie options. | ||
* @returns {any} The deserialized value associated with the key. | ||
* @returns {T} The deserialized value associated with the key. | ||
*/ | ||
putObjectIfAbsent(key: string, ifAbsent: () => unknown, options?: import("./cookie_options.js").CookieOptionsParams | undefined): any; | ||
putObjectIfAbsent<T_1>(key: string, ifAbsent: () => T_1, options?: import("./cookie_options.js").CookieOptionsParams | undefined): T_1; | ||
/** | ||
@@ -95,8 +97,9 @@ * Removes the value associated with the specified key. | ||
* Serializes and associates a given `value` with the specified `key`. | ||
* @template T | ||
* @param {string} key The cookie name. | ||
* @param {any} value The cookie value. | ||
* @param {T} value The cookie value. | ||
* @param {import("./cookie_options.js").CookieOptionsParams} [options] The cookie options. | ||
* @returns {this} This instance. | ||
*/ | ||
setObject(key: string, value: any, options?: import("./cookie_options.js").CookieOptionsParams | undefined): this; | ||
setObject<T_2>(key: string, value: T_2, options?: import("./cookie_options.js").CookieOptionsParams | undefined): this; | ||
/** | ||
@@ -103,0 +106,0 @@ * Returns a JSON representation of this object. |
@@ -0,0 +0,0 @@ export * from "./cookie_event.js"; |
@@ -0,0 +0,0 @@ /** |
{ | ||
"bugs": "https://github.com/cedx/cookies.js/issues", | ||
"description": "Service for interacting with the HTTP cookies.", | ||
"homepage": "https://github.com/cedx/cookies.js", | ||
"homepage": "https://docs.belin.io/cookies.js", | ||
"license": "MIT", | ||
@@ -9,3 +9,3 @@ "name": "@cedx/cookies", | ||
"type": "module", | ||
"version": "5.0.1", | ||
"version": "5.1.0", | ||
"author": { | ||
@@ -17,16 +17,9 @@ "email": "cedric@belin.io", | ||
"devDependencies": { | ||
"@babel/eslint-parser": "^7.19.1", | ||
"@babel/plugin-syntax-import-assertions": "^7.20.0", | ||
"@esm-bundle/chai": "^4.3.4", | ||
"@types/gulp": "^4.0.10", | ||
"@esm-bundle/chai": "^4.3.4-fix.0", | ||
"@types/mocha": "^10.0.1", | ||
"@types/node": "^18.14.0", | ||
"@web/test-runner": "^0.15.0", | ||
"@web/test-runner-playwright": "^0.9.0", | ||
"del": "^7.0.0", | ||
"eslint": "^8.34.0", | ||
"execa": "^7.0.0", | ||
"gulp": "^4.0.2", | ||
"typedoc": "^0.23.25", | ||
"typescript": "^4.9.5" | ||
"@web/test-runner": "^0.17.0", | ||
"@web/test-runner-playwright": "^0.10.1", | ||
"eslint": "^8.47.0", | ||
"typedoc": "^0.24.8", | ||
"typescript": "^5.1.6" | ||
}, | ||
@@ -60,5 +53,11 @@ "engines": { | ||
"scripts": { | ||
"prepack": "gulp", | ||
"build": "tsc --project src/jsconfig.json", | ||
"clean": "node scripts/clean.js", | ||
"doc": "typedoc --options etc/typedoc.json && node scripts/doc.js", | ||
"dist": "npm run clean && npm run build", | ||
"lint": "tsc --project jsconfig.json && eslint --config=etc/eslint.json etc example scripts src test", | ||
"postpublish": "node scripts/publish.js", | ||
"prepack": "npm run dist", | ||
"test": "web-test-runner --config=etc/test_runner.js" | ||
} | ||
} |
# Cookies for JS | ||
![Runtime](https://badgen.net/npm/node/@cedx/cookies) ![Release](https://badgen.net/npm/v/@cedx/cookies) ![License](https://badgen.net/npm/license/@cedx/cookies) ![Downloads](https://badgen.net/npm/dt/@cedx/cookies) ![Coverage](https://badgen.net/codecov/c/github/cedx/cookies.js) | ||
![Node.js](https://badgen.net/npm/node/@cedx/cookies) ![npm](https://badgen.net/npm/v/@cedx/cookies) ![License](https://badgen.net/npm/license/@cedx/cookies) ![Downloads](https://badgen.net/npm/dt/@cedx/cookies) ![Coverage](https://badgen.net/codecov/c/github/cedx/cookies.js) | ||
Yet another service for interacting with the [HTTP cookies](https://developer.mozilla.org/docs/Web/HTTP/Cookies) | ||
Service for interacting with the [HTTP cookies](https://developer.mozilla.org/docs/Web/HTTP/Cookies) | ||
in [JavaScript](https://developer.mozilla.org/docs/Web/JavaScript). | ||
## Documentation | ||
- [User guide](https://github.com/cedx/cookies.js/wiki) | ||
- [API reference](https://cedx.github.io/cookies.js) | ||
- [User guide](https://docs.belin.io/cookies.js) | ||
- [API reference](https://docs.belin.io/cookies.js/api) | ||
@@ -17,2 +17,2 @@ ## Development | ||
## License | ||
[Cookies for JS](https://github.com/cedx/cookies.js) is distributed under the MIT License. | ||
[Cookies for JS](https://docs.belin.io/cookies.js) is distributed under the MIT License. |
@@ -89,4 +89,5 @@ import {CookieEvent} from "./cookie_event.js"; | ||
* Gets the deserialized value associated with the specified key. | ||
* @template T | ||
* @param {string} key The cookie name. | ||
* @returns {any} The cookie value, or `null` if the key does not exist or the value cannot be deserialized. | ||
* @returns {T|null} The cookie value, or `null` if the key does not exist or the value cannot be deserialized. | ||
*/ | ||
@@ -129,10 +130,11 @@ getObject(key) { | ||
* Looks up the deserialized value of the specified key, or add a new serialized value if it isn't there. | ||
* @template T | ||
* @param {string} key The cookie name. | ||
* @param {() => unknown} ifAbsent A function producing the new cookie value. | ||
* @param {() => T} ifAbsent A function producing the new cookie value. | ||
* @param {import("./cookie_options.js").CookieOptionsParams} [options] The cookie options. | ||
* @returns {any} The deserialized value associated with the key. | ||
* @returns {T} The deserialized value associated with the key. | ||
*/ | ||
putObjectIfAbsent(key, ifAbsent, options = {}) { | ||
if (!this.has(key)) this.setObject(key, ifAbsent(), options); | ||
return this.getObject(key); | ||
return /** @type {T} */ (this.getObject(key)); | ||
} | ||
@@ -176,4 +178,5 @@ | ||
* Serializes and associates a given `value` with the specified `key`. | ||
* @template T | ||
* @param {string} key The cookie name. | ||
* @param {any} value The cookie value. | ||
* @param {T} value The cookie value. | ||
* @param {import("./cookie_options.js").CookieOptionsParams} [options] The cookie options. | ||
@@ -180,0 +183,0 @@ * @returns {this} This instance. |
Sorry, the diff of this file is not supported yet
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
No website
QualityPackage does not have a website.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
7
627
0
26749
1