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
Hello! I've encountered an error in rxjs published as latest (7.8.1 as of writing this)
I've built a simple iterable structure for a specific task. It also had a length property, since I needed to check for that in my operator function.
When I've put that iterable object into from, it did nothing. Some digging showed up that innerFrom treats anything with length property as array just by having that said property and not being a function.
Either isArrayLike should be changed in some way to fit the fromArrayLike or order of checks should be different, so that iterables that are not arrays, but have length property, would be treated as iterables
Expected behavior
from({ [Symbol.iterable](): { ... }, get length() { ... } }) should treat argument as iterable
Reproduction code
import'./style.css';import{from}from'rxjs';exportclassExample<T>implementsIterable<T>{privateitems: T[]=[];publicadd(item: T){this.items.push(item);}// comment this getter out to see the differencepublicgetlength(){returnthis.items.length;}private*generator(){for(leti=0;i<this.items.length;i++){yieldthis.items[i];}}[Symbol.iterator](): Iterator<T,any,undefined>{returnthis.generator();}}constqueue=newExample<string>();queue.add('kek');queue.add('lol');queue.add('wut');for(constvalueofqueue){console.log(value);}from(queue).subscribe((value)=>console.log(value));// look at the console// the "for" loop logs values correctly// while observable thing does that only if "length" getter is commented out
Describe the bug
Hello! I've encountered an error in rxjs published as latest (7.8.1 as of writing this)
I've built a simple iterable structure for a specific task. It also had a length property, since I needed to check for that in my operator function.
When I've put that iterable object into
from
, it did nothing. Some digging showed up thatinnerFrom
treats anything withlength
property as array just by having that said property and not being a function.Either
isArrayLike
should be changed in some way to fit thefromArrayLike
or order of checks should be different, so that iterables that are not arrays, but havelength
property, would be treated as iterablesExpected behavior
from({ [Symbol.iterable](): { ... }, get length() { ... } })
should treat argument as iterableReproduction code
The text was updated successfully, but these errors were encountered: