Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lodash removal #237

Merged
merged 2 commits into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Pimm marked this conversation as resolved.
Show resolved Hide resolved
);
}
}
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