js-cookie 3.0.0-rc.2 → 3.0.1
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 +4 -19
- package/dist/js.cookie.js +122 -106
- package/dist/js.cookie.min.js +2 -0
- package/dist/js.cookie.min.mjs +2 -2
- package/dist/js.cookie.mjs +14 -9
- package/package.json +22 -18
- package/dist/js.cookie.umd.js +0 -142
- package/dist/js.cookie.umd.min.js +0 -2
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://travis-ci.com/js-cookie/js-cookie) [](https://www.browserstack.com/automate/public-build/b3VDaHAxVDg0NDdCRmtUOWg0SlQzK2NsRVhWTjlDQS9qdGJoak1GMzJiVT0tLVhwZHNvdGRoY284YVRrRnI3eU1JTnc9PQ==--5e88ffb3ca116001d7ef2cfb97a4128ac31174c2) [](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,8 +17,8 @@ A simple, lightweight JavaScript API for handling cookies
|
|
|
17
17
|
- Enable [custom encoding/decoding](#converters)
|
|
18
18
|
- **< 800 bytes** gzipped!
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
[View documentation for the latest release.](https://github.com/js-cookie/js-cookie/tree/latest#readme)
|
|
20
|
+
**👉👉 If you're viewing this at https://github.com/js-cookie/js-cookie, you're reading the documentation for the master branch.
|
|
21
|
+
[View documentation for the latest release.](https://github.com/js-cookie/js-cookie/tree/latest#readme) 👈👈**
|
|
22
22
|
|
|
23
23
|
## Installation
|
|
24
24
|
|
|
@@ -60,22 +60,7 @@ Here we're loading the nomodule script in a deferred fashion, because ES modules
|
|
|
60
60
|
|
|
61
61
|
### CDN
|
|
62
62
|
|
|
63
|
-
Alternatively, include it via [jsDelivr CDN](https://www.jsdelivr.com/package/npm/js-cookie)
|
|
64
|
-
|
|
65
|
-
UMD:
|
|
66
|
-
|
|
67
|
-
```html
|
|
68
|
-
<script src="https://cdn.jsdelivr.net/npm/js-cookie@rc/dist/js.cookie.min.js"></script>
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
ES module:
|
|
72
|
-
|
|
73
|
-
```html
|
|
74
|
-
<script
|
|
75
|
-
type="module"
|
|
76
|
-
src="https://cdn.jsdelivr.net/npm/js-cookie@rc/dist/js.cookie.min.mjs"
|
|
77
|
-
></script>
|
|
78
|
-
```
|
|
63
|
+
Alternatively, include it via [jsDelivr CDN](https://www.jsdelivr.com/package/npm/js-cookie).
|
|
79
64
|
|
|
80
65
|
## ES Module
|
|
81
66
|
|
package/dist/js.cookie.js
CHANGED
|
@@ -1,131 +1,147 @@
|
|
|
1
|
-
/*! js-cookie v3.0.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
/*! js-cookie v3.0.1 | MIT */
|
|
2
|
+
;
|
|
3
|
+
(function (global, factory) {
|
|
4
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
5
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
6
|
+
(global = global || self, (function () {
|
|
7
|
+
var current = global.Cookies;
|
|
8
|
+
var exports = global.Cookies = factory();
|
|
9
|
+
exports.noConflict = function () { global.Cookies = current; return exports; };
|
|
10
|
+
}()));
|
|
11
|
+
}(this, (function () { 'use strict';
|
|
12
|
+
|
|
13
|
+
/* eslint-disable no-var */
|
|
14
|
+
function assign (target) {
|
|
15
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
16
|
+
var source = arguments[i];
|
|
17
|
+
for (var key in source) {
|
|
18
|
+
target[key] = source[key];
|
|
19
|
+
}
|
|
9
20
|
}
|
|
21
|
+
return target
|
|
10
22
|
}
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
var defaultConverter = {
|
|
15
|
-
read: function (value) {
|
|
16
|
-
return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent)
|
|
17
|
-
},
|
|
18
|
-
write: function (value) {
|
|
19
|
-
return encodeURIComponent(value).replace(
|
|
20
|
-
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
|
|
21
|
-
decodeURIComponent
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
};
|
|
23
|
+
/* eslint-enable no-var */
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
/* eslint-disable no-var */
|
|
26
|
+
var defaultConverter = {
|
|
27
|
+
read: function (value) {
|
|
28
|
+
if (value[0] === '"') {
|
|
29
|
+
value = value.slice(1, -1);
|
|
30
|
+
}
|
|
31
|
+
return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent)
|
|
32
|
+
},
|
|
33
|
+
write: function (value) {
|
|
34
|
+
return encodeURIComponent(value).replace(
|
|
35
|
+
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
|
|
36
|
+
decodeURIComponent
|
|
37
|
+
)
|
|
30
38
|
}
|
|
39
|
+
};
|
|
40
|
+
/* eslint-enable no-var */
|
|
31
41
|
|
|
32
|
-
|
|
42
|
+
/* eslint-disable no-var */
|
|
33
43
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
key = encodeURIComponent(key)
|
|
42
|
-
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)
|
|
43
|
-
.replace(/[()]/g, escape);
|
|
44
|
+
function init (converter, defaultAttributes) {
|
|
45
|
+
function set (key, value, attributes) {
|
|
46
|
+
if (typeof document === 'undefined') {
|
|
47
|
+
return
|
|
48
|
+
}
|
|
44
49
|
|
|
45
|
-
|
|
50
|
+
attributes = assign({}, defaultAttributes, attributes);
|
|
46
51
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
if (typeof attributes.expires === 'number') {
|
|
53
|
+
attributes.expires = new Date(Date.now() + attributes.expires * 864e5);
|
|
54
|
+
}
|
|
55
|
+
if (attributes.expires) {
|
|
56
|
+
attributes.expires = attributes.expires.toUTCString();
|
|
51
57
|
}
|
|
52
58
|
|
|
53
|
-
|
|
59
|
+
key = encodeURIComponent(key)
|
|
60
|
+
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)
|
|
61
|
+
.replace(/[()]/g, escape);
|
|
54
62
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
var stringifiedAttributes = '';
|
|
64
|
+
for (var attributeName in attributes) {
|
|
65
|
+
if (!attributes[attributeName]) {
|
|
66
|
+
continue
|
|
67
|
+
}
|
|
58
68
|
|
|
59
|
-
|
|
60
|
-
// ...
|
|
61
|
-
// 3. If the remaining unparsed-attributes contains a %x3B (";")
|
|
62
|
-
// character:
|
|
63
|
-
// Consume the characters of the unparsed-attributes up to,
|
|
64
|
-
// not including, the first %x3B (";") character.
|
|
65
|
-
// ...
|
|
66
|
-
stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
|
|
67
|
-
}
|
|
69
|
+
stringifiedAttributes += '; ' + attributeName;
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
if (attributes[attributeName] === true) {
|
|
72
|
+
continue
|
|
73
|
+
}
|
|
71
74
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
// Considers RFC 6265 section 5.2:
|
|
76
|
+
// ...
|
|
77
|
+
// 3. If the remaining unparsed-attributes contains a %x3B (";")
|
|
78
|
+
// character:
|
|
79
|
+
// Consume the characters of the unparsed-attributes up to,
|
|
80
|
+
// not including, the first %x3B (";") character.
|
|
81
|
+
// ...
|
|
82
|
+
stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
|
|
83
|
+
}
|
|
76
84
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
var jar = {};
|
|
81
|
-
for (var i = 0; i < cookies.length; i++) {
|
|
82
|
-
var parts = cookies[i].split('=');
|
|
83
|
-
var value = parts.slice(1).join('=');
|
|
85
|
+
return (document.cookie =
|
|
86
|
+
key + '=' + converter.write(value, key) + stringifiedAttributes)
|
|
87
|
+
}
|
|
84
88
|
|
|
85
|
-
|
|
86
|
-
|
|
89
|
+
function get (key) {
|
|
90
|
+
if (typeof document === 'undefined' || (arguments.length && !key)) {
|
|
91
|
+
return
|
|
87
92
|
}
|
|
88
93
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
// To prevent the for loop in the first place assign an empty array
|
|
95
|
+
// in case there are no cookies at all.
|
|
96
|
+
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
|
97
|
+
var jar = {};
|
|
98
|
+
for (var i = 0; i < cookies.length; i++) {
|
|
99
|
+
var parts = cookies[i].split('=');
|
|
100
|
+
var value = parts.slice(1).join('=');
|
|
101
|
+
|
|
102
|
+
try {
|
|
103
|
+
var foundKey = decodeURIComponent(parts[0]);
|
|
104
|
+
jar[foundKey] = converter.read(value, foundKey);
|
|
105
|
+
|
|
106
|
+
if (key === foundKey) {
|
|
107
|
+
break
|
|
108
|
+
}
|
|
109
|
+
} catch (e) {}
|
|
110
|
+
}
|
|
92
111
|
|
|
93
|
-
|
|
94
|
-
break
|
|
95
|
-
}
|
|
96
|
-
} catch (e) {}
|
|
112
|
+
return key ? jar[key] : jar
|
|
97
113
|
}
|
|
98
114
|
|
|
99
|
-
return
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
return Object.create(
|
|
116
|
+
{
|
|
117
|
+
set: set,
|
|
118
|
+
get: get,
|
|
119
|
+
remove: function (key, attributes) {
|
|
120
|
+
set(
|
|
121
|
+
key,
|
|
122
|
+
'',
|
|
123
|
+
assign({}, attributes, {
|
|
124
|
+
expires: -1
|
|
125
|
+
})
|
|
126
|
+
);
|
|
127
|
+
},
|
|
128
|
+
withAttributes: function (attributes) {
|
|
129
|
+
return init(this.converter, assign({}, this.attributes, attributes))
|
|
130
|
+
},
|
|
131
|
+
withConverter: function (converter) {
|
|
132
|
+
return init(assign({}, this.converter, converter), this.attributes)
|
|
133
|
+
}
|
|
117
134
|
},
|
|
118
|
-
|
|
119
|
-
|
|
135
|
+
{
|
|
136
|
+
attributes: { value: Object.freeze(defaultAttributes) },
|
|
137
|
+
converter: { value: Object.freeze(converter) }
|
|
120
138
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
)
|
|
127
|
-
}
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
var api = init(defaultConverter, { path: '/' });
|
|
143
|
+
/* eslint-enable no-var */
|
|
128
144
|
|
|
129
|
-
|
|
145
|
+
return api;
|
|
130
146
|
|
|
131
|
-
|
|
147
|
+
})));
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! js-cookie v3.0.1 | MIT */
|
|
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}return 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:"/"})}));
|
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=
|
|
1
|
+
/*! js-cookie v3.0.1 | 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 default t;
|
package/dist/js.cookie.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
/*! js-cookie v3.0.
|
|
1
|
+
/*! js-cookie v3.0.1 | MIT */
|
|
2
|
+
/* eslint-disable no-var */
|
|
2
3
|
function assign (target) {
|
|
3
4
|
for (var i = 1; i < arguments.length; i++) {
|
|
4
5
|
var source = arguments[i];
|
|
@@ -8,9 +9,14 @@ function assign (target) {
|
|
|
8
9
|
}
|
|
9
10
|
return target
|
|
10
11
|
}
|
|
12
|
+
/* eslint-enable no-var */
|
|
11
13
|
|
|
14
|
+
/* eslint-disable no-var */
|
|
12
15
|
var defaultConverter = {
|
|
13
16
|
read: function (value) {
|
|
17
|
+
if (value[0] === '"') {
|
|
18
|
+
value = value.slice(1, -1);
|
|
19
|
+
}
|
|
14
20
|
return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent)
|
|
15
21
|
},
|
|
16
22
|
write: function (value) {
|
|
@@ -20,6 +26,9 @@ var defaultConverter = {
|
|
|
20
26
|
)
|
|
21
27
|
}
|
|
22
28
|
};
|
|
29
|
+
/* eslint-enable no-var */
|
|
30
|
+
|
|
31
|
+
/* eslint-disable no-var */
|
|
23
32
|
|
|
24
33
|
function init (converter, defaultAttributes) {
|
|
25
34
|
function set (key, value, attributes) {
|
|
@@ -40,8 +49,6 @@ function init (converter, defaultAttributes) {
|
|
|
40
49
|
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)
|
|
41
50
|
.replace(/[()]/g, escape);
|
|
42
51
|
|
|
43
|
-
value = converter.write(value, key);
|
|
44
|
-
|
|
45
52
|
var stringifiedAttributes = '';
|
|
46
53
|
for (var attributeName in attributes) {
|
|
47
54
|
if (!attributes[attributeName]) {
|
|
@@ -64,7 +71,8 @@ function init (converter, defaultAttributes) {
|
|
|
64
71
|
stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
|
|
65
72
|
}
|
|
66
73
|
|
|
67
|
-
return (document.cookie =
|
|
74
|
+
return (document.cookie =
|
|
75
|
+
key + '=' + converter.write(value, key) + stringifiedAttributes)
|
|
68
76
|
}
|
|
69
77
|
|
|
70
78
|
function get (key) {
|
|
@@ -80,12 +88,8 @@ function init (converter, defaultAttributes) {
|
|
|
80
88
|
var parts = cookies[i].split('=');
|
|
81
89
|
var value = parts.slice(1).join('=');
|
|
82
90
|
|
|
83
|
-
if (value[0] === '"') {
|
|
84
|
-
value = value.slice(1, -1);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
91
|
try {
|
|
88
|
-
var foundKey =
|
|
92
|
+
var foundKey = decodeURIComponent(parts[0]);
|
|
89
93
|
jar[foundKey] = converter.read(value, foundKey);
|
|
90
94
|
|
|
91
95
|
if (key === foundKey) {
|
|
@@ -125,5 +129,6 @@ function init (converter, defaultAttributes) {
|
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
var api = init(defaultConverter, { path: '/' });
|
|
132
|
+
/* eslint-enable no-var */
|
|
128
133
|
|
|
129
134
|
export default api;
|
package/package.json
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js-cookie",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
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",
|
|
7
|
-
"unpkg": "dist/js.cookie.
|
|
8
|
-
"jsdelivr": "dist/js.cookie.
|
|
7
|
+
"unpkg": "dist/js.cookie.min.js",
|
|
8
|
+
"jsdelivr": "dist/js.cookie.min.js",
|
|
9
9
|
"exports": {
|
|
10
|
-
"
|
|
11
|
-
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/js.cookie.mjs",
|
|
12
|
+
"require": "./dist/js.cookie.js"
|
|
13
|
+
},
|
|
14
|
+
"./package.json": "./package.json"
|
|
12
15
|
},
|
|
13
16
|
"directories": {
|
|
14
17
|
"test": "test"
|
|
@@ -41,28 +44,29 @@
|
|
|
41
44
|
"license": "MIT",
|
|
42
45
|
"devDependencies": {
|
|
43
46
|
"browserstack-runner": "^0.9.0",
|
|
44
|
-
"eslint": "^
|
|
45
|
-
"eslint-config-standard": "^
|
|
47
|
+
"eslint": "^7.31.0",
|
|
48
|
+
"eslint-config-standard": "^16.0.3",
|
|
49
|
+
"eslint-plugin-promise": "^5.1.0",
|
|
46
50
|
"eslint-plugin-html": "^6.0.0",
|
|
47
|
-
"eslint-plugin-markdown": "^
|
|
51
|
+
"eslint-plugin-markdown": "^2.2.0",
|
|
48
52
|
"grunt": "^1.0.4",
|
|
49
53
|
"grunt-compare-size": "^0.4.2",
|
|
50
|
-
"grunt-contrib-connect": "^
|
|
51
|
-
"grunt-contrib-nodeunit": "^
|
|
54
|
+
"grunt-contrib-connect": "^3.0.0",
|
|
55
|
+
"grunt-contrib-nodeunit": "^3.0.0",
|
|
52
56
|
"grunt-contrib-qunit": "^3.1.0",
|
|
53
57
|
"grunt-contrib-watch": "^1.1.0",
|
|
54
58
|
"grunt-exec": "^3.0.0",
|
|
55
59
|
"gzip-js": "^0.3.2",
|
|
56
|
-
"prettier": "^
|
|
60
|
+
"prettier": "^2.3.2",
|
|
57
61
|
"qunit": "^2.9.3",
|
|
58
|
-
"release-it": "^
|
|
62
|
+
"release-it": "^14.10.0",
|
|
59
63
|
"rollup": "^2.0.0",
|
|
60
|
-
"rollup-plugin-filesize": "^
|
|
61
|
-
"rollup-plugin-license": "^
|
|
62
|
-
"rollup-plugin-terser": "^
|
|
63
|
-
"standard": "^
|
|
64
|
+
"rollup-plugin-filesize": "^9.1.1",
|
|
65
|
+
"rollup-plugin-license": "^2.5.0",
|
|
66
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
67
|
+
"standard": "^16.0.3"
|
|
64
68
|
},
|
|
65
69
|
"engines": {
|
|
66
|
-
"node": ">=
|
|
70
|
+
"node": ">=12"
|
|
67
71
|
}
|
|
68
72
|
}
|
package/dist/js.cookie.umd.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/*! js-cookie v3.0.0-rc.2 | MIT */
|
|
2
|
-
;
|
|
3
|
-
(function (global, factory) {
|
|
4
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
5
|
-
typeof define === 'function' && define.amd ? define(factory) :
|
|
6
|
-
(global = global || self, (function () {
|
|
7
|
-
var current = global.Cookies;
|
|
8
|
-
var exports = global.Cookies = factory();
|
|
9
|
-
exports.noConflict = function () { global.Cookies = current; return exports; };
|
|
10
|
-
}()));
|
|
11
|
-
}(this, (function () { 'use strict';
|
|
12
|
-
|
|
13
|
-
function assign (target) {
|
|
14
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
15
|
-
var source = arguments[i];
|
|
16
|
-
for (var key in source) {
|
|
17
|
-
target[key] = source[key];
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return target
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
var defaultConverter = {
|
|
24
|
-
read: function (value) {
|
|
25
|
-
return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent)
|
|
26
|
-
},
|
|
27
|
-
write: function (value) {
|
|
28
|
-
return encodeURIComponent(value).replace(
|
|
29
|
-
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
|
|
30
|
-
decodeURIComponent
|
|
31
|
-
)
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
function init (converter, defaultAttributes) {
|
|
36
|
-
function set (key, value, attributes) {
|
|
37
|
-
if (typeof document === 'undefined') {
|
|
38
|
-
return
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
attributes = assign({}, defaultAttributes, attributes);
|
|
42
|
-
|
|
43
|
-
if (typeof attributes.expires === 'number') {
|
|
44
|
-
attributes.expires = new Date(Date.now() + attributes.expires * 864e5);
|
|
45
|
-
}
|
|
46
|
-
if (attributes.expires) {
|
|
47
|
-
attributes.expires = attributes.expires.toUTCString();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
key = encodeURIComponent(key)
|
|
51
|
-
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)
|
|
52
|
-
.replace(/[()]/g, escape);
|
|
53
|
-
|
|
54
|
-
value = converter.write(value, key);
|
|
55
|
-
|
|
56
|
-
var stringifiedAttributes = '';
|
|
57
|
-
for (var attributeName in attributes) {
|
|
58
|
-
if (!attributes[attributeName]) {
|
|
59
|
-
continue
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
stringifiedAttributes += '; ' + attributeName;
|
|
63
|
-
|
|
64
|
-
if (attributes[attributeName] === true) {
|
|
65
|
-
continue
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Considers RFC 6265 section 5.2:
|
|
69
|
-
// ...
|
|
70
|
-
// 3. If the remaining unparsed-attributes contains a %x3B (";")
|
|
71
|
-
// character:
|
|
72
|
-
// Consume the characters of the unparsed-attributes up to,
|
|
73
|
-
// not including, the first %x3B (";") character.
|
|
74
|
-
// ...
|
|
75
|
-
stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return (document.cookie = key + '=' + value + stringifiedAttributes)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function get (key) {
|
|
82
|
-
if (typeof document === 'undefined' || (arguments.length && !key)) {
|
|
83
|
-
return
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// To prevent the for loop in the first place assign an empty array
|
|
87
|
-
// in case there are no cookies at all.
|
|
88
|
-
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
|
89
|
-
var jar = {};
|
|
90
|
-
for (var i = 0; i < cookies.length; i++) {
|
|
91
|
-
var parts = cookies[i].split('=');
|
|
92
|
-
var value = parts.slice(1).join('=');
|
|
93
|
-
|
|
94
|
-
if (value[0] === '"') {
|
|
95
|
-
value = value.slice(1, -1);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
try {
|
|
99
|
-
var foundKey = defaultConverter.read(parts[0]);
|
|
100
|
-
jar[foundKey] = converter.read(value, foundKey);
|
|
101
|
-
|
|
102
|
-
if (key === foundKey) {
|
|
103
|
-
break
|
|
104
|
-
}
|
|
105
|
-
} catch (e) {}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return key ? jar[key] : jar
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return Object.create(
|
|
112
|
-
{
|
|
113
|
-
set: set,
|
|
114
|
-
get: get,
|
|
115
|
-
remove: function (key, attributes) {
|
|
116
|
-
set(
|
|
117
|
-
key,
|
|
118
|
-
'',
|
|
119
|
-
assign({}, attributes, {
|
|
120
|
-
expires: -1
|
|
121
|
-
})
|
|
122
|
-
);
|
|
123
|
-
},
|
|
124
|
-
withAttributes: function (attributes) {
|
|
125
|
-
return init(this.converter, assign({}, this.attributes, attributes))
|
|
126
|
-
},
|
|
127
|
-
withConverter: function (converter) {
|
|
128
|
-
return init(assign({}, this.converter, converter), this.attributes)
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
attributes: { value: Object.freeze(defaultAttributes) },
|
|
133
|
-
converter: { value: Object.freeze(converter) }
|
|
134
|
-
}
|
|
135
|
-
)
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
var api = init(defaultConverter, { path: '/' });
|
|
139
|
-
|
|
140
|
-
return api;
|
|
141
|
-
|
|
142
|
-
})));
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! js-cookie v3.0.0-rc.2 | MIT */
|
|
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,r=e.Cookies=t();r.noConflict=function(){return e.Cookies=n,r}}())}(this,function(){"use strict";function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}var t={read:function(e){return 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)}};return function n(r,o){function i(t,n,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),n=r.write(n,t);var c="";for(var u in i)i[u]&&(c+="; "+u,!0!==i[u]&&(c+="="+i[u].split(";")[0]));return document.cookie=t+"="+n+c}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},i=0;i<n.length;i++){var c=n[i].split("="),u=c.slice(1).join("=");'"'===u[0]&&(u=u.slice(1,-1));try{var f=t.read(c[0]);if(o[f]=r.read(u,f),e===f)break}catch(e){}}return e?o[e]:o}},remove:function(t,n){i(t,"",e({},n,{expires:-1}))},withAttributes:function(t){return n(this.converter,e({},this.attributes,t))},withConverter:function(t){return n(e({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(o)},converter:{value:Object.freeze(r)}})}(t,{path:"/"})});
|