js-cookie 3.0.1 → 3.0.2
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/README.md +7 -19
- package/dist/js.cookie.js +18 -18
- package/dist/js.cookie.min.js +2 -2
- package/dist/js.cookie.min.mjs +2 -2
- package/dist/js.cookie.mjs +15 -15
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<img src="https://cloud.githubusercontent.com/assets/835857/14581711/ba623018-0436-11e6-8fce-d2ccd4d379c9.gif">
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
|
-
# JavaScript Cookie [](https://github.com/js-cookie/js-cookie/actions/workflows/ci.yml) [](https://github.com/js-cookie/js-cookie/actions/workflows/browserstack.yml) [](https://standardjs.com) [](https://codeclimate.com/github/js-cookie/js-cookie) [](https://www.npmjs.com/package/js-cookie) [](https://www.npmjs.com/package/js-cookie) [](https://www.jsdelivr.com/package/npm/js-cookie)
|
|
6
6
|
|
|
7
7
|
A simple, lightweight JavaScript API for handling cookies
|
|
8
8
|
|
|
@@ -17,7 +17,7 @@ A simple, lightweight JavaScript API for handling cookies
|
|
|
17
17
|
- Enable [custom encoding/decoding](#converters)
|
|
18
18
|
- **< 800 bytes** gzipped!
|
|
19
19
|
|
|
20
|
-
**👉👉 If you're viewing this at https://github.com/js-cookie/js-cookie, you're reading the documentation for the
|
|
20
|
+
**👉👉 If you're viewing this at https://github.com/js-cookie/js-cookie, you're reading the documentation for the main branch.
|
|
21
21
|
[View documentation for the latest release.](https://github.com/js-cookie/js-cookie/tree/latest#readme) 👈👈**
|
|
22
22
|
|
|
23
23
|
## Installation
|
|
@@ -26,8 +26,8 @@ A simple, lightweight JavaScript API for handling cookies
|
|
|
26
26
|
|
|
27
27
|
JavaScript Cookie supports [npm](https://www.npmjs.com/package/js-cookie) under the name `js-cookie`.
|
|
28
28
|
|
|
29
|
-
```
|
|
30
|
-
|
|
29
|
+
```bash
|
|
30
|
+
npm i js-cookie
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
The npm package has a `module` field pointing to an ES module variant of the library, mainly to provide support for ES module aware bundlers, whereas its `browser` field points to an UMD module for full backward compatibility.
|
|
@@ -301,8 +301,8 @@ Cookies.withConverter({
|
|
|
301
301
|
|
|
302
302
|
## TypeScript declarations
|
|
303
303
|
|
|
304
|
-
```
|
|
305
|
-
|
|
304
|
+
```bash
|
|
305
|
+
npm i @types/js-cookie
|
|
306
306
|
```
|
|
307
307
|
|
|
308
308
|
## Server-side integration
|
|
@@ -319,19 +319,7 @@ For vulnerability reports, send an e-mail to `js-cookie at googlegroups dot com`
|
|
|
319
319
|
|
|
320
320
|
## Releasing
|
|
321
321
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
Start a dry run to see what would happen:
|
|
325
|
-
|
|
326
|
-
```
|
|
327
|
-
$ npm run release minor -- --dry-run
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
Do a real release (publishes both to npm as well as create a new release on GitHub):
|
|
331
|
-
|
|
332
|
-
```
|
|
333
|
-
$ npm run release minor
|
|
334
|
-
```
|
|
322
|
+
For releasing there's the `Release` GitHub Actions workflow, which will create a new release along with package provenance on npmjs.com.
|
|
335
323
|
|
|
336
324
|
_GitHub releases are created as a draft and need to be published manually!
|
|
337
325
|
(This is so we are able to craft suitable release notes before publishing.)_
|
package/dist/js.cookie.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/*! js-cookie v3.0.
|
|
1
|
+
/*! js-cookie v3.0.2 | MIT */
|
|
2
2
|
;
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
5
5
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
6
|
-
(global = global || self, (function () {
|
|
6
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (function () {
|
|
7
7
|
var current = global.Cookies;
|
|
8
8
|
var exports = global.Cookies = factory();
|
|
9
9
|
exports.noConflict = function () { global.Cookies = current; return exports; };
|
|
10
|
-
}())
|
|
11
|
-
}(this, (function () { 'use strict';
|
|
10
|
+
})());
|
|
11
|
+
})(this, (function () { 'use strict';
|
|
12
12
|
|
|
13
13
|
/* eslint-disable no-var */
|
|
14
14
|
function assign (target) {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
/* eslint-disable no-var */
|
|
43
43
|
|
|
44
44
|
function init (converter, defaultAttributes) {
|
|
45
|
-
function set (
|
|
45
|
+
function set (name, value, attributes) {
|
|
46
46
|
if (typeof document === 'undefined') {
|
|
47
47
|
return
|
|
48
48
|
}
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
attributes.expires = attributes.expires.toUTCString();
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
name = encodeURIComponent(name)
|
|
60
60
|
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)
|
|
61
61
|
.replace(/[()]/g, escape);
|
|
62
62
|
|
|
@@ -83,11 +83,11 @@
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
return (document.cookie =
|
|
86
|
-
|
|
86
|
+
name + '=' + converter.write(value, name) + stringifiedAttributes)
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
function get (
|
|
90
|
-
if (typeof document === 'undefined' || (arguments.length && !
|
|
89
|
+
function get (name) {
|
|
90
|
+
if (typeof document === 'undefined' || (arguments.length && !name)) {
|
|
91
91
|
return
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -100,25 +100,25 @@
|
|
|
100
100
|
var value = parts.slice(1).join('=');
|
|
101
101
|
|
|
102
102
|
try {
|
|
103
|
-
var
|
|
104
|
-
jar[
|
|
103
|
+
var found = decodeURIComponent(parts[0]);
|
|
104
|
+
jar[found] = converter.read(value, found);
|
|
105
105
|
|
|
106
|
-
if (
|
|
106
|
+
if (name === found) {
|
|
107
107
|
break
|
|
108
108
|
}
|
|
109
109
|
} catch (e) {}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
return
|
|
112
|
+
return name ? jar[name] : jar
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
return Object.create(
|
|
116
116
|
{
|
|
117
|
-
set
|
|
118
|
-
get
|
|
119
|
-
remove: function (
|
|
117
|
+
set,
|
|
118
|
+
get,
|
|
119
|
+
remove: function (name, attributes) {
|
|
120
120
|
set(
|
|
121
|
-
|
|
121
|
+
name,
|
|
122
122
|
'',
|
|
123
123
|
assign({}, attributes, {
|
|
124
124
|
expires: -1
|
|
@@ -144,4 +144,4 @@
|
|
|
144
144
|
|
|
145
145
|
return api;
|
|
146
146
|
|
|
147
|
-
}))
|
|
147
|
+
}));
|
package/dist/js.cookie.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! js-cookie v3.0.
|
|
2
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self,function(){var n=e.Cookies,o=e.Cookies=t();o.noConflict=function(){return e.Cookies=n,o}}())}(this,(function(){"use strict";function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}
|
|
1
|
+
/*! js-cookie v3.0.2 | MIT */
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self,function(){var n=e.Cookies,o=e.Cookies=t();o.noConflict=function(){return e.Cookies=n,o}}())}(this,(function(){"use strict";function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}var t=function t(n,o){function r(t,r,i){if("undefined"!=typeof document){"number"==typeof(i=e({},o,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var c="";for(var u in i)i[u]&&(c+="; "+u,!0!==i[u]&&(c+="="+i[u].split(";")[0]));return document.cookie=t+"="+n.write(r,t)+c}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var t=document.cookie?document.cookie.split("; "):[],o={},r=0;r<t.length;r++){var i=t[r].split("="),c=i.slice(1).join("=");try{var u=decodeURIComponent(i[0]);if(o[u]=n.read(c,u),e===u)break}catch(e){}}return e?o[e]:o}},remove:function(t,n){r(t,"",e({},n,{expires:-1}))},withAttributes:function(n){return t(this.converter,e({},this.attributes,n))},withConverter:function(n){return t(e({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(o)},converter:{value:Object.freeze(n)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});return t}));
|
package/dist/js.cookie.min.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! js-cookie v3.0.
|
|
2
|
-
function e(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)e[n]=r[n]}return e}var t=function t(r,n){function o(t,o,i){if("undefined"!=typeof document){"number"==typeof(i=e({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var c="";for(var u in i)i[u]&&(c+="; "+u,!0!==i[u]&&(c+="="+i[u].split(";")[0]));return document.cookie=t+"="+r.write(o,t)+c}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var t=document.cookie?document.cookie.split("; "):[],n={},o=0;o<t.length;o++){var i=t[o].split("="),c=i.slice(1).join("=");try{var u=decodeURIComponent(i[0]);if(n[u]=r.read(c,u),e===u)break}catch(e){}}return e?n[e]:n}},remove:function(t,r){o(t,"",e({},r,{expires:-1}))},withAttributes:function(r){return t(this.converter,e({},this.attributes,r))},withConverter:function(r){return t(e({},this.converter,r),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(r)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});export default
|
|
1
|
+
/*! js-cookie v3.0.2 | MIT */
|
|
2
|
+
function e(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)e[n]=r[n]}return e}var t=function t(r,n){function o(t,o,i){if("undefined"!=typeof document){"number"==typeof(i=e({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var c="";for(var u in i)i[u]&&(c+="; "+u,!0!==i[u]&&(c+="="+i[u].split(";")[0]));return document.cookie=t+"="+r.write(o,t)+c}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var t=document.cookie?document.cookie.split("; "):[],n={},o=0;o<t.length;o++){var i=t[o].split("="),c=i.slice(1).join("=");try{var u=decodeURIComponent(i[0]);if(n[u]=r.read(c,u),e===u)break}catch(e){}}return e?n[e]:n}},remove:function(t,r){o(t,"",e({},r,{expires:-1}))},withAttributes:function(r){return t(this.converter,e({},this.attributes,r))},withConverter:function(r){return t(e({},this.converter,r),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(r)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});export{t as default};
|
package/dist/js.cookie.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! js-cookie v3.0.
|
|
1
|
+
/*! js-cookie v3.0.2 | MIT */
|
|
2
2
|
/* eslint-disable no-var */
|
|
3
3
|
function assign (target) {
|
|
4
4
|
for (var i = 1; i < arguments.length; i++) {
|
|
@@ -31,7 +31,7 @@ var defaultConverter = {
|
|
|
31
31
|
/* eslint-disable no-var */
|
|
32
32
|
|
|
33
33
|
function init (converter, defaultAttributes) {
|
|
34
|
-
function set (
|
|
34
|
+
function set (name, value, attributes) {
|
|
35
35
|
if (typeof document === 'undefined') {
|
|
36
36
|
return
|
|
37
37
|
}
|
|
@@ -45,7 +45,7 @@ function init (converter, defaultAttributes) {
|
|
|
45
45
|
attributes.expires = attributes.expires.toUTCString();
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
name = encodeURIComponent(name)
|
|
49
49
|
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)
|
|
50
50
|
.replace(/[()]/g, escape);
|
|
51
51
|
|
|
@@ -72,11 +72,11 @@ function init (converter, defaultAttributes) {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
return (document.cookie =
|
|
75
|
-
|
|
75
|
+
name + '=' + converter.write(value, name) + stringifiedAttributes)
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
function get (
|
|
79
|
-
if (typeof document === 'undefined' || (arguments.length && !
|
|
78
|
+
function get (name) {
|
|
79
|
+
if (typeof document === 'undefined' || (arguments.length && !name)) {
|
|
80
80
|
return
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -89,25 +89,25 @@ function init (converter, defaultAttributes) {
|
|
|
89
89
|
var value = parts.slice(1).join('=');
|
|
90
90
|
|
|
91
91
|
try {
|
|
92
|
-
var
|
|
93
|
-
jar[
|
|
92
|
+
var found = decodeURIComponent(parts[0]);
|
|
93
|
+
jar[found] = converter.read(value, found);
|
|
94
94
|
|
|
95
|
-
if (
|
|
95
|
+
if (name === found) {
|
|
96
96
|
break
|
|
97
97
|
}
|
|
98
98
|
} catch (e) {}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
return
|
|
101
|
+
return name ? jar[name] : jar
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
return Object.create(
|
|
105
105
|
{
|
|
106
|
-
set
|
|
107
|
-
get
|
|
108
|
-
remove: function (
|
|
106
|
+
set,
|
|
107
|
+
get,
|
|
108
|
+
remove: function (name, attributes) {
|
|
109
109
|
set(
|
|
110
|
-
|
|
110
|
+
name,
|
|
111
111
|
'',
|
|
112
112
|
assign({}, attributes, {
|
|
113
113
|
expires: -1
|
|
@@ -131,4 +131,4 @@ function init (converter, defaultAttributes) {
|
|
|
131
131
|
var api = init(defaultConverter, { path: '/' });
|
|
132
132
|
/* eslint-enable no-var */
|
|
133
133
|
|
|
134
|
-
export default
|
|
134
|
+
export { api as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js-cookie",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "A simple, lightweight JavaScript API for handling cookies",
|
|
5
5
|
"browser": "dist/js.cookie.js",
|
|
6
6
|
"module": "dist/js.cookie.mjs",
|
|
@@ -43,30 +43,30 @@
|
|
|
43
43
|
"author": "Klaus Hartl",
|
|
44
44
|
"license": "MIT",
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"
|
|
46
|
+
"@rollup/plugin-terser": "^0.4.0",
|
|
47
|
+
"browserstack-runner": "github:browserstack/browserstack-runner#1e85e559951bdf97ffe2a7c744ee67ca83589fde",
|
|
47
48
|
"eslint": "^7.31.0",
|
|
48
49
|
"eslint-config-standard": "^16.0.3",
|
|
49
|
-
"eslint-plugin-
|
|
50
|
-
"eslint-plugin-
|
|
51
|
-
"eslint-plugin-markdown": "^2.2.0",
|
|
50
|
+
"eslint-plugin-html": "^7.0.0",
|
|
51
|
+
"eslint-plugin-markdown": "^3.0.0",
|
|
52
52
|
"grunt": "^1.0.4",
|
|
53
53
|
"grunt-compare-size": "^0.4.2",
|
|
54
54
|
"grunt-contrib-connect": "^3.0.0",
|
|
55
|
-
"grunt-contrib-nodeunit": "^
|
|
56
|
-
"grunt-contrib-qunit": "^
|
|
55
|
+
"grunt-contrib-nodeunit": "^5.0.0",
|
|
56
|
+
"grunt-contrib-qunit": "^7.0.0",
|
|
57
57
|
"grunt-contrib-watch": "^1.1.0",
|
|
58
58
|
"grunt-exec": "^3.0.0",
|
|
59
59
|
"gzip-js": "^0.3.2",
|
|
60
60
|
"prettier": "^2.3.2",
|
|
61
61
|
"qunit": "^2.9.3",
|
|
62
|
-
"release-it": "^
|
|
63
|
-
"rollup": "^
|
|
64
|
-
"rollup-plugin-filesize": "^
|
|
65
|
-
"rollup-plugin-license": "^
|
|
66
|
-
"
|
|
67
|
-
"standard": "^16.0.3"
|
|
62
|
+
"release-it": "^15.0.0",
|
|
63
|
+
"rollup": "^3.17.2",
|
|
64
|
+
"rollup-plugin-filesize": "^10.0.0",
|
|
65
|
+
"rollup-plugin-license": "^3.0.0",
|
|
66
|
+
"standard": "^17.0.0"
|
|
68
67
|
},
|
|
69
68
|
"engines": {
|
|
70
|
-
"node": ">=
|
|
69
|
+
"node": ">=14",
|
|
70
|
+
"npm": ">=9.5.0"
|
|
71
71
|
}
|
|
72
72
|
}
|