Created
June 6, 2019 23:25
-
-
Save arturovt/8f6674adb0b2e3d9b6269f0e9dbc4396 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class CountriesService implements Mutateble<Country> { | |
| public mutateSource( | |
| countries: Country[], | |
| key: keyof Country, | |
| value: Country[keyof Country] | |
| ): Country[] { | |
| countries.forEach((country) => { | |
| country[key] = value; | |
| }); // BAD | |
| for (const country of countries) { | |
| country[key] = value; | |
| } // GOOD | |
| for (let i = 0, length = countries.length; i < length; i++) { | |
| const country = countries[i]; | |
| country[key] = value; | |
| } // GOOD | |
| return countries; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment