Refactor onUseUnuse function in SE instance
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=348404) </details> <!--IssueSummary end--> The following discussion from !76489 should be addressed: - [ ] @himkp started a [discussion](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/76489#note_770887039): (+2 comments) > Suggestion: It seems that we have a little more abstraction than necessary, just to support a singular extension definition and an array of extension definitions. Ideally, I'd like to see us using restparams, so that works for both singular and multiple extensions. > > Anyways, this function can be simplified to: > > ```js > static useUnuse(extensionsStore, fn, extensions) { > return extensions.length > ? extensions.map(fn.bind(this, extensionsStore)) > : fn.call(this, extensionsStore, extensions); > } > ``` > > If we agree to use restparams for `extensions`, this can be further simplified to: > > ```js > static useUnuse(extensionsStore, fn, ext0, ...extN) { > return [ext0, ...extN].map(fn.bind(this, extensionsStore)); > } > ``` > > At which point, I would recommend removing this function and using the one liner in both `useExtension` and `unuseExtension` functions. We can also combine `use` and `useExtension` (and `unuse` and `unuseExtension`) functions into one.
issue