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
Ability to initialize an ArraySchema from an iterator or a regular array (Array<>)
Using spread operator like this: new ArraySchema<string>(...arrayofstrings) can lead to a stack overflow error.
This would also allow constructing from things like map.keys() which cannot be spread, and the current solution is only to construct an iterator and add to ArraySchema one at a time.
Optional: Proposed API
A static method from in ArraySchema could accept any object with a forEach iterator.
Alternatively, could make the constructor or push function smarter. Since ArraySchema is typed, we could know that when ArraySchema<string>.push is called with a Array<string>, that it should concat instead of attempting to just push on the array as if it was a string. This is less consistent with Array<>, but unlike with Array<> the ArraySchema currently throws an error.
The text was updated successfully, but these errors were encountered:
Description & Use case
Ability to initialize an ArraySchema from an iterator or a regular array (Array<>)
Using spread operator like this:
new ArraySchema<string>(...arrayofstrings)
can lead to a stack overflow error.This would also allow constructing from things like
map.keys()
which cannot be spread, and the current solution is only to construct an iterator and add to ArraySchema one at a time.Optional: Proposed API
A static method
from
in ArraySchema could accept any object with aforEach
iterator.Alternatively, could make the constructor or push function smarter. Since ArraySchema is typed, we could know that when
ArraySchema<string>.push
is called with aArray<string>
, that it should concat instead of attempting to just push on the array as if it was a string. This is less consistent withArray<>
, but unlike withArray<>
the ArraySchema currently throws an error.The text was updated successfully, but these errors were encountered: