Skip to content

Commit

Permalink
Merge pull request #237 from mollie/pimm/lodash-removal
Browse files Browse the repository at this point in the history
Removed Lodash.
  • Loading branch information
Pimm authored Nov 15, 2021
2 parents 5a1d556 + ff02380 commit 9452519
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
"lint": "yarn lint:eslint:fix && yarn lint:prettier"
},
"dependencies": {
"axios": "^0.21.1",
"lodash": "^4.17.21"
"axios": "^0.21.1"
},
"devDependencies": {
"@babel/plugin-proposal-class-properties": "^7.14.5",
Expand Down
4 changes: 1 addition & 3 deletions src/data/payments/PaymentHelper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { get } from 'lodash';

import renege from '../../plumbing/renege';
import undefinedPromise from '../../plumbing/undefinedPromise';
import TransformingNetworkClient from '../../TransformingNetworkClient';
Expand Down Expand Up @@ -79,7 +77,7 @@ export default class PaymentHelper extends Helper<PaymentData, Payment> {
* Returns the URL the customer should visit to make the payment. This is to where you should redirect the consumer.
*/
public getPaymentUrl(): Nullable<string> {
return get(this.links, 'checkout.href', null);
return this.links.checkout?.href ?? null;
}

/**
Expand Down
13 changes: 6 additions & 7 deletions src/errors/ApiError.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { AxiosResponse } from 'axios';
import { cloneDeep, get, has } from 'lodash';

import { MollieApiErrorLinks, Url } from '../data/global';
import Maybe from '../types/Maybe';
Expand Down Expand Up @@ -67,7 +66,7 @@ export default class ApiError extends Error {
* @since 3.0.0
*/
public hasLink(key: string): boolean {
return has(this.links, key);
return this.links !== undefined && key in this.links;
}

/**
Expand Down Expand Up @@ -97,11 +96,11 @@ export default class ApiError extends Error {
*/
public static createFromResponse(response: AxiosResponse): ApiError {
return new ApiError(
get(response, 'data.detail', 'Received an error without a message'),
get(response, 'data.title'),
get(response, 'data.status'),
get(response, 'data.field'),
cloneDeep(get(response, 'data._links')),
response.data.detail ?? 'Received an error without a message',
response.data.title,
response.data.status,
response.data.field,
response.data._links,
);
}
}
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4547,7 +4547,7 @@ lodash.truncate@^4.4.2:
resolved "https://registry.yarnpkg.com/lodash.truncate/-/lodash.truncate-4.4.2.tgz#5a350da0b1113b837ecfffd5812cbe58d6eae193"
integrity sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=

lodash@^4.17.12, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21:
lodash@^4.17.12, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
Expand Down

0 comments on commit 9452519

Please sign in to comment.