Add IndexOf, LastIndexOf, IndicesOf, CountOf types#1155
Add IndexOf, LastIndexOf, IndicesOf, CountOf types#1155benzaria wants to merge 12 commits intosindresorhus:mainfrom
IndexOf, LastIndexOf, IndicesOf, CountOf types#1155Conversation
…se` types **External** - `IndexOf` Returns the index of the first occurrence of a value in an array, or -1 if it is not present. - `LastIndexOf` Returns the index of the last occurrence of a value in an array, or -1 if it is not present. - `AllIndexOf` Return an array of indexes of all the occurrences of a value in an array, or [] if it is not present. - `CountOf` Return the count of all the occurrences of a value in an array, or 0 if it is not present. - `ArrayReverse` Reverse an array.
|
@som-sm Hi, can u review this Please. Thanks ! |
|
Looks ok to me 👍 We cannot really review in detail without tests.
|
| /** | ||
| Simpler version of Sum<T, 1>, without the extra logic. | ||
| */ | ||
| export type Increment<T extends number> = SumPositives<T, 1>; |
There was a problem hiding this comment.
Why are you exporting it? It's not used elsewhere.
There was a problem hiding this comment.
Ohh i forgot about it i was using it in a arithmetic types I'm working on to Improve Sum, Substract with a range of 10999 number, with also Multiplication, Division. do u consider adding does types or it just to much ?
…nexpose Increment type
@benzaria If you want to understand the feasibility of a type, please consider opening an issue first. Because without proper tests it doesn't really make sense to review the PR. |
|
Also, please submit one type per PR, unless the types are closely related. Once you start handling various edge cases, the implementations can become quite verbose and complex, so separating them into individual PRs makes a lot of sense. And even for simpler types, it's best to keep them in separate PRs whenever possible. |
IndexOf, LastIndexOf, AllIndexOf, CountOf and ArrayReverse typesIndexOf, LastIndexOf, IndicesOf, CountOf and ArrayReverse types
…litOnSpread for reversing arrays with spread element
IndexOf, LastIndexOf, IndicesOf, CountOf and ArrayReverse typesIndexOf, LastIndexOf, IndicesOf, CountOf, Reverse, SplitOnSpread and ExtractStrict types
som-sm
left a comment
There was a problem hiding this comment.
Also, please submit one type per PR, unless the types are closely related. Once you start handling various edge cases, the implementations can become quite verbose and complex, so separating them into individual PRs makes a lot of sense.
And even for simpler types, it's best to keep them in separate PRs whenever possible.
Doesn't make sense to add seven different types in one single PR. I'd rather prefer seven independent PRs.
Here’s what I’d suggest:
Pick one of the seven types, open a PR just for that, and get it reviewed and merged. Once you're familiar with the process and expectations, you can move on to opening PRs for the remaining types.
CC: @sindresorhus
|
@som-sm @sindresorhus Hey guys, I'm so sorry for the many types I made in this PRs. I know it's better to separate them in diff PRs. but when a type relies on the other it's not ideal take for example the Making a PRs for each individual type and wait to merge will take a lot of time, and will delay the contribution. the |
IndexOf, LastIndexOf, IndicesOf, CountOf, Reverse, SplitOnSpread and ExtractStrict typesIndexOf, LastIndexOf, IndicesOf, CountOf types
Equivelent to
Array.prototype.[ indexOf | lastIndexOf ]External
IndexOfReturns the index of the first occurrence of a value in an array, or -1 if it is not present.LastIndexOfReturns the index of the last occurrence of a value in an array, or -1 if it is not present.IndicesOfReturn an array of indexes of all the occurrences of a value in an array, or [] if it is not present.CountOfReturn the count of all the occurrences of a value in an array, or 0 if it is not present.IncludesModified to useIndexOf