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

Allow readonly arrays as inputs #129

Merged
merged 2 commits into from
Sep 15, 2021

Conversation

diesieben07
Copy link
Contributor

What:
The items parameter of matchSorter as well as the keys option are being changed to ReadonlyArray from a plain Array. This more closely represents the contract of the function, as it does not modify these arrays.
Fixes #128.

Why:
Even though matchSorter does not modify its input array, it cannot be called with a value of type ReadonlyArray:

const input: readonly string[] = ['foo', 'bar', 'baz'];
matchSorter(input, 'f'); // does not compile

How:
The required changes are simple: The input types are changed to ReadyonlyArray. This is not a breaking change, as Array is a subtype of ReadonlyArray in typescript, so "normal arrays" can be passed in like before.

Checklist:

  • Documentation N/A - The fact a new array is returned is already present in the documentation
  • Tests N/A
  • Ready to be merged

@codecov
Copy link

codecov bot commented Sep 15, 2021

Codecov Report

Merging #129 (3a49b43) into main (fba154b) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #129   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines          163       163           
  Branches        39        39           
=========================================
  Hits           163       163           
Impacted Files Coverage Δ
src/index.ts 100.00% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fba154b...3a49b43. Read the comment docs.

@kentcdodds kentcdodds merged commit 6ce7833 into kentcdodds:main Sep 15, 2021
@kentcdodds
Copy link
Owner

@all-contributors please add @diesieben07 for code

@allcontributors
Copy link
Contributor

@kentcdodds

I've put up a pull request to add @diesieben07! 🎉

@github-actions
Copy link

🎉 This PR is included in version 6.3.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

matchSorter does not accept readonly arrays.
2 participants