es-cookies
Advanced tools
Comparing version 2.1.12 to 2.1.13
@@ -8,12 +8,44 @@ 'use strict'; | ||
// src/cookie.coffee | ||
var Cookie; | ||
// src/cookies.coffee | ||
var Cookies; | ||
Cookie = class Cookie { | ||
contructor(defaults = {}) { | ||
this.defaults = defaults; | ||
Cookies = (function() { | ||
function Cookies(defaults) { | ||
this.defaults = defaults != null ? defaults : {}; | ||
this.get = (function(_this) { | ||
return function(key) { | ||
return _this.api(key); | ||
}; | ||
})(this); | ||
this.remove = (function(_this) { | ||
return function(key, attrs) { | ||
return _this.api(key, '', objectAssign({ | ||
expires: -1 | ||
}, attrs)); | ||
}; | ||
})(this); | ||
this.set = (function(_this) { | ||
return function(key, value, attrs) { | ||
return _this.api(key, value, attrs); | ||
}; | ||
})(this); | ||
this.getJSON = (function(_this) { | ||
return function(key) { | ||
var err, val; | ||
val = _this.api(key); | ||
if (val == null) { | ||
return {}; | ||
} | ||
try { | ||
return JSON.parse(val); | ||
} catch (error) { | ||
err = error; | ||
return val; | ||
} | ||
}; | ||
})(this); | ||
} | ||
api(key, value, attrs) { | ||
var attr, cookie, cookies, err, expires, i, name, parts, rdecode, result, strAttrs; | ||
Cookies.prototype.api = function(key, value, attrs) { | ||
var attr, cookie, cookies, err, expires, i, kv, len, name, parts, rdecode, result, strAttrs; | ||
if (typeof document === 'undefined') { | ||
@@ -63,5 +95,5 @@ return; | ||
rdecode = /(%[0-9A-Z]{2})+/g; | ||
i = 0; | ||
while (i < cookies.length) { | ||
parts = cookies[i].split('='); | ||
for (i = 0, len = cookies.length; i < len; i++) { | ||
kv = cookies[i]; | ||
parts = kv.split('='); | ||
cookie = parts.slice(1).join('='); | ||
@@ -75,4 +107,3 @@ if (cookie.charAt(0) === '"') { | ||
if (key === name) { | ||
result = cookie; | ||
break; | ||
return cookie; | ||
} | ||
@@ -87,36 +118,14 @@ if (!key) { | ||
return result; | ||
} | ||
}; | ||
get(key) { | ||
return this.api.get(key); | ||
} | ||
return Cookies; | ||
getJSON(key) { | ||
var err; | ||
try { | ||
return JSON.parse(this.api.get(key)); | ||
} catch (error) { | ||
err = error; | ||
return {}; | ||
} | ||
} | ||
})(); | ||
set(key, value, attrs) { | ||
return this.api(key, value, attrs); | ||
} | ||
var Cookies$1 = Cookies; | ||
remove(key, attrs) { | ||
return this.api(key, '', objectAssign(attrs, { | ||
expires: -1 | ||
})); | ||
} | ||
}; | ||
var Cookie$1 = Cookie; | ||
// src/index.coffee | ||
var index = new Cookie$1(); | ||
var index = new Cookies$1(); | ||
module.exports = index; | ||
//# sourceMappingURL=cookies.js.map |
{ | ||
"name": "es-cookies", | ||
"version": "2.1.12", | ||
"version": "2.1.13", | ||
"description": "Module-friendly fork of js-cookie. A simple, lightweight JavaScript API for handling cookies", | ||
@@ -43,5 +43,5 @@ "main": "lib/cookies.js", | ||
"coffee-script": "1.12.4", | ||
"handroll": "0.13.1", | ||
"qunitjs": "2.3.0", | ||
"shortcake": "1.2.8" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
48665
14
444
0