question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is this implementation of endWith correct

See original GitHub issue

Bug Report

rxjs 6.5.1 implements endWith as follows:

export function endWith<T>(...array: Array<T | SchedulerLike>): MonoTypeOperatorFunction<T> {
  return (source: Observable<T>) => concat(source, ...(array as any[])) as Observable<T>;
}

Is this really correct given that concat expects observables as input, but array carries the individual items?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
cartantcommented, Apr 25, 2019

This is a really interesting bug. The tests pass because strings are iterable - so they are valid observable inputs. If the tests had used values other than strings, they would have failed!

4reactions
cartantcommented, Apr 25, 2019

@CarstenLeue Looks like a bug, to me. But the fix is a little more subtle, as the array could contain a Scheduler. The array will need to be spread into a call to of, instead of being passed to from.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to implement a "EndsWith" on a string? - Stack Overflow
This will add a Java-like endsWith method to String: String.prototype. ... You can then do: "w,w,a,$,b,c".endsWith(s1) //true.
Read more >
String endsWith​ Method Example in Java - Medium
This method returns true if the string is ending with given string or ... Internal implementation of endsWith method in Java String class....
Read more >
String.prototype.endsWith() - JavaScript - MDN Web Docs
The endsWith() method determines whether a string ends with the characters of a specified string, returning true or false as appropriate.
Read more >
Python String endswith() Method - Tutorialspoint
The python string endswith() method checks if the input string ends with the specified suffix. This function returns true if the string ends...
Read more >
JavaScript String endsWith() Method - W3Schools
Definition and Usage. The endsWith() method returns true if a string ends with a specified string. Otherwise it returns false .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found