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
If you don't mind me asking, why is the main Itiriri class not exported? It would make it easier to extend it and add more methods.
As it stands, one is left with two options, both sub-optimal:
copy the entire source of the Itiriri class, just to add a couple metods
fiddle with prototypes at runtime
Right now I'm going with option 2:
importitiriri,{IterableQuery}from'itiriri'importequalfrom'@wry/equality'// extend the IterableQuery interface for the type checkerdeclare module 'itiriri'{exportinterfaceIterableQuery<T>{/** * Returns `true` if this sequence is equal to the given sequence. */equals(other: Iterable<T>): boolean}}// export a function with a new name so that the IDE knows to import from hereexportdefaultfunctionfrom<T>(source: Iterable<T>): IterableQuery<T>{returnitiriri(source)}// HACK: obtain a reference to the Itiriri class from an instanceconstItiriri=itiriri([]).constructor// implement the extensionsItiriri.prototype.equals=function<T>(other: Iterable<T>): boolean{constas=this[Symbol.iterator]()constbs=other[Symbol.iterator]()while(true){consta=as.next()constb=bs.next()if(a.done&&b.done)returntrueif(a.done!==b.done||!equal(a.value,b.value))returnfalse}}
If you don't mind me asking, why is the main Itiriri class not exported? It would make it easier to extend it and add more methods.
As it stands, one is left with two options, both sub-optimal:
Right now I'm going with option 2:
Client code:
The text was updated successfully, but these errors were encountered: