History

Sanity-check decaffeinate class CookiesStore

Simon Legner committed 2 years ago

Commit c1a424f1 parent c595b2b1 file · +2 −12Browse files

Unified · Split

assets/javascripts/lib/cookies_store.js+2−12
@@ -1,13 +1,3 @@
1// TODO: This file was created by bulk-decaffeinate.
2// Sanity-check the conversion and remove this comment.
3/*
4 * decaffeinate suggestions:
5 * DS101: Remove unnecessary use of Array.from
6 * DS102: Remove unnecessary code created because of implicit returns
7 * DS206: Consider reworking classes to avoid initClass
8 * DS207: Consider shorter variations of null checks
9 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
10 */
11// Intentionally called CookiesStore instead of CookieStore1// Intentionally called CookiesStore instead of CookieStore
12// Calling it CookieStore causes issues when the Experimental Web Platform features flag is enabled in Chrome2// Calling it CookieStore causes issues when the Experimental Web Platform features flag is enabled in Chrome
13// Related issue: https://github.com/freeCodeCamp/devdocs/issues/9323// Related issue: https://github.com/freeCodeCamp/devdocs/issues/932
@@ -53,7 +43,7 @@ class CookiesStore { · 39 unmodified lines
53 43
54 reset() {44 reset() {
55 try {45 try {
56 for (var cookie of Array.from(document.cookie.split(/;\s?/))) {46 for (var cookie of document.cookie.split(/;\s?/)) {
57 Cookies.expire(cookie.split("=")[0]);47 Cookies.expire(cookie.split("=")[0]);
58 }48 }
59 return;49 return;
@@ -62,7 +52,7 @@ class CookiesStore { · 2 unmodified lines
62 52
63 dump() {53 dump() {
64 const result = {};54 const result = {};
65 for (var cookie of Array.from(document.cookie.split(/;\s?/))) {55 for (var cookie of document.cookie.split(/;\s?/)) {
66 if (cookie[0] !== "_") {56 if (cookie[0] !== "_") {
67 cookie = cookie.split("=");57 cookie = cookie.split("=");
68 result[cookie[0]] = cookie[1];58 result[cookie[0]] = cookie[1];