Skip to content

Commit

Permalink
Merge pull request #263 from chmelevskij/fix/remove-mixed-imports
Browse files Browse the repository at this point in the history
fix(universal-cookie): remove object-assign
  • Loading branch information
eXon authored Sep 22, 2020
2 parents bb68224 + 9ff7df5 commit f80e99a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
4 changes: 1 addition & 3 deletions packages/universal-cookie/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
},
"dependencies": {
"@types/cookie": "^0.3.3",
"@types/object-assign": "^4.0.30",
"cookie": "^0.4.0",
"object-assign": "^4.1.1"
"cookie": "^0.4.0"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
Expand Down
13 changes: 5 additions & 8 deletions packages/universal-cookie/src/Cookies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ import {
} from './types';
import { hasDocumentCookie, parseCookies, readCookie } from './utils';

// We can't please Rollup and TypeScript at the same time
// Only way to make both of them work
const objectAssign = require('object-assign');

export default class Cookies {
private cookies: { [name: string]: Cookie };
private changeListeners: CookieChangeListener[] = [];
Expand Down Expand Up @@ -73,7 +69,7 @@ export default class Cookies {
value = JSON.stringify(value);
}

this.cookies = objectAssign({}, this.cookies, { [name]: value });
this.cookies = { ...this.cookies, [name]: value };

if (this.HAS_DOCUMENT_COOKIE) {
document.cookie = cookie.serialize(name, value, options);
Expand All @@ -83,12 +79,13 @@ export default class Cookies {
}

public remove(name: string, options?: CookieSetOptions) {
const finalOptions = (options = objectAssign({}, options, {
const finalOptions = (options = {
...options,
expires: new Date(1970, 1, 1, 0, 0, 1),
maxAge: 0
}));
});

this.cookies = objectAssign({}, this.cookies);
this.cookies = { ...this.cookies };
delete this.cookies[name];

if (this.HAS_DOCUMENT_COOKIE) {
Expand Down

0 comments on commit f80e99a

Please sign in to comment.