amadeus4dev / amadeus-node

Node library for the Amadeus Self-Service travel APIs
https://developers.amadeus.com
MIT License
191 stars 66 forks source link

Refactored needsLoadOrRefresh method #208

Closed darseen closed 9 months ago

darseen commented 9 months ago

Refactor needsLoadOrRefresh() method

Changes Made

Refactored the needsLoadOrRefresh() method for improved readability. The logic remains the same, but the code structure has been enhanced.

Before

needsLoadOrRefresh() {
    if (!this.accessToken) { return true; }
    else if ((Date.now() + TOKEN_BUFFER) > this.expiresAt) { return true; }
    else { return false; }
}

After

needsLoadOrRefresh() {
    return !this.accessToken || (Date.now() + TOKEN_BUFFER) > this.expiresAt;
}

Testing

All tests have been executed, and the changes have passed successfully.

sonarcloud[bot] commented 9 months ago

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

minjikarin commented 9 months ago

Thank you @Darseen :) confirmed that all test are passed.