Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 1x 1x 1x 1x 1x 3x 1x | /**
* 提供对 cookie 的读写能力
* - 写入时自动用 encodeURIComponent 编码
* - 读取时自动用 decodeURIComponent 解码
* @module cookie/cookie
* @see https://www.npmjs.com/package/js-cookie
* @example
* var $cookie = require('@spore-ui/kit/packages/cookie/cookie');
* $cookie.set('name', '中文', {
* expires: 1
* });
* $cookie.read('name') // '中文'
*/
var Cookie = require('js-cookie');
var instance = Cookie;
Eif (Cookie.withConverter) {
instance = Cookie.withConverter({
read: function (val) {
return decodeURIComponent(val);
},
write: function (val) {
return encodeURIComponent(val);
},
});
}
module.exports = instance;
|