@massimo-cassandro/minimo 1.20.3 → 1.20.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/src/utilities/cookies.js +10 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@massimo-cassandro/minimo",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.5",
|
|
4
4
|
"description": "Light css framework & utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -86,16 +86,16 @@
|
|
|
86
86
|
}
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
-
"@massimo-cassandro/eslint-config": "^3.0.
|
|
90
|
-
"@massimo-cassandro/stylelint-config": "^2.3.
|
|
91
|
-
"@types/node": "^26.1.
|
|
89
|
+
"@massimo-cassandro/eslint-config": "^3.0.13",
|
|
90
|
+
"@massimo-cassandro/stylelint-config": "^2.3.13",
|
|
91
|
+
"@types/node": "^26.1.2",
|
|
92
92
|
"jsdom": "^29.1.1",
|
|
93
93
|
"style-dictionary": "^5.5.0"
|
|
94
94
|
},
|
|
95
95
|
"dependencies": {
|
|
96
96
|
"@inquirer/input": "^5.1.2",
|
|
97
97
|
"@inquirer/select": "^5.2.1",
|
|
98
|
-
"clipboardy": "^5.3.
|
|
98
|
+
"clipboardy": "^5.3.2",
|
|
99
99
|
"sharp": "^0.35.3",
|
|
100
100
|
"sharp-ico": "^0.1.5",
|
|
101
101
|
"svgo": "^4.0.2"
|
package/src/utilities/cookies.js
CHANGED
|
@@ -4,12 +4,19 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Returns the value of a cookie by name.
|
|
6
6
|
* @param {string} name
|
|
7
|
-
* @
|
|
7
|
+
* @param {object} [options]
|
|
8
|
+
* @param {boolean} [options.parseJson=false] - If true, JSON-parses the value and returns an object instead of a string.
|
|
9
|
+
* @returns {string | object | null}
|
|
8
10
|
*/
|
|
9
|
-
export function getCookie(name) {
|
|
11
|
+
export function getCookie(name, {parseJson = false} = {}) {
|
|
10
12
|
const value = `; ${document.cookie}`;
|
|
11
13
|
const parts = value.split(`; ${name}=`);
|
|
12
|
-
if (parts.length
|
|
14
|
+
if (parts.length !== 2) return null;
|
|
15
|
+
|
|
16
|
+
const cookieValue = parts.pop()?.split(';').shift();
|
|
17
|
+
if (cookieValue === undefined) return null;
|
|
18
|
+
|
|
19
|
+
return parseJson ? JSON.parse(cookieValue) : cookieValue;
|
|
13
20
|
}
|
|
14
21
|
|
|
15
22
|
|