Title: fix: rgbToHsl no longer mutates its input array by InukaWijerathna · Pull Request #1908 · TheAlgorithms/JavaScript · GitHub
Open Graph Title: fix: rgbToHsl no longer mutates its input array by InukaWijerathna · Pull Request #1908 · TheAlgorithms/JavaScript
X Title: fix: rgbToHsl no longer mutates its input array by InukaWijerathna · Pull Request #1908 · TheAlgorithms/JavaScript
Description: Closes #1907. rgbToHsl aliased its argument (let colorHsl = colorRgb) instead of copying it, then wrote the HSL result into that same array and returned it. Any caller that kept a reference to its RGB input had that array silently overwritten with the HSL output (input === result was true). Fixes the alias to a copy ([...colorRgb]), per the fix suggested in the issue, and adds a regression test asserting the input array is left unchanged after conversion. The existing HSL conversion math is untouched — only the in-place mutation is fixed.
Open Graph Description: Closes #1907. rgbToHsl aliased its argument (let colorHsl = colorRgb) instead of copying it, then wrote the HSL result into that same array and returned it. Any caller that kept a reference to its ...
X Description: Closes #1907. rgbToHsl aliased its argument (let colorHsl = colorRgb) instead of copying it, then wrote the HSL result into that same array and returned it. Any caller that kept a reference to its ...
Opengraph URL: https://github.com/TheAlgorithms/JavaScript/pull/1908
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:5f60d1f6-cdca-b169-ab87-79e472645b7f |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D710:D2C58:3C28122:3DC347A:6A63502F |
| html-safe-nonce | 6b29f51c41365026c7c0a7edbdcf28db778b3d61846e4bb4fe73001e63677708 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENzEwOkQyQzU4OjNDMjgxMjI6M0RDMzQ3QTo2QTYzNTAyRiIsInZpc2l0b3JfaWQiOiI0NzY0NzQwODAwNDYyNjcxOTE5IiwicmVnaW9uX2VkZ2UiOiJzZWEiLCJyZWdpb25fcmVuZGVyIjoic2VhIn0= |
| visitor-hmac | 157f165f300488e18f4bc982bee45248d5779f76c9e38d7c2fe13747f48e1723 |
| hovercard-subject-tag | pull_request:3946397918 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/TheAlgorithms/JavaScript/pull/1908/files |
| twitter:image | https://avatars.githubusercontent.com/u/180553425?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/180553425?s=400&v=4 |
| og:image:alt | Closes #1907. rgbToHsl aliased its argument (let colorHsl = colorRgb) instead of copying it, then wrote the HSL result into that same array and returned it. Any caller that kept a reference to its ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 59e55daad7174ca59d63c6974d58276ccb5477442e550bebb3c035e1bef11c94 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/TheAlgorithms/JavaScript git https://github.com/TheAlgorithms/JavaScript.git |
| octolytics-dimension-user_id | 20487725 |
| octolytics-dimension-user_login | TheAlgorithms |
| octolytics-dimension-repository_id | 97086543 |
| octolytics-dimension-repository_nwo | TheAlgorithms/JavaScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 97086543 |
| octolytics-dimension-repository_network_root_nwo | TheAlgorithms/JavaScript |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 990295d92a4cc7b63fbbd83a046217cd7d77d49c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width