You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** Returns a new array including the first `n` elements of the provided array, or an empty array if `n` is either negative or greater than the length of the provided array. */
however if n is greater than the length of the array, the whole array is returned instead of an empty array.
for example:
console.log(A.take([1,2,3],10));
logs [ 1, 2, 3 ] whereas it should log [].
when using a negative n this does correctly print out an empty array.
for example:
console.log(A.take([1,2,3],-10));
logs [].
The text was updated successfully, but these errors were encountered:
The current behavior is more natural/usable. As the take function is just an alias for A.slice(0, x), it should take all elements when the index surpasses the array's length. So, I think the documentation should be matched to its behavior. for the strict action for the take action, we already have one: takeExactly
But that's my opinion, If the purpose of the A.take was what the docs said, the code should be changed. But I'm also scared because some of the codes I wrote work based on the current behavior.
The docs for
A.take
state:ts-belt/src/Array/index.ts
Line 147 in c825d97
however if
n
is greater than the length of the array, the whole array is returned instead of an empty array.for example:
logs
[ 1, 2, 3 ]
whereas it should log[]
.when using a negative
n
this does correctly print out an empty array.for example:
logs
[]
.The text was updated successfully, but these errors were encountered: