Replacing the continuity of $f$ in limit of composite functions with another condition. I know that, if $f$ is continuous on $\lim\limits_{x \to a} g(x)=L$ then $\lim\limits_{x \to a} f(g(x))= \lim\limits_{y\to L} f(y) =f \left( \lim\limits_{x \to a } g(x) \right)$ $\ldots (*)$.
I was wondering if can you replace continuity of $f$ with some other condition? So I found one condition, which I'll write down below.

Asuming that $\lim\limits_{x \to a} g(x)=L$ and for every $\delta\gt0$ there exist an $\eta\gt 0$ such that $g$ takes all values on $(L-\eta,L+\eta)$, except perhaps $L$ itself, on $(a-\delta,a+\delta)-\{a\}$ then I want to show that $(*)$ holds.
EDIT: I'm also assuming all the limits in $(*)$ exist.

I can show that $\lim\limits_{x \to a} f(g(x))= \lim\limits_{y \to L}f(y)$ but I'm not sure how to show the last part that the two limits also equal $f \left( \lim\limits_{x \to a}g(x) \right)$ or $f(L)$ which seems to assume continuity of $f$ on $L$ but I have to show that from only those conditions I have mentioned. Any help? And if it doesn't follow, can we produce a counterexample?
I have taken the condition from an answer here on stackexchange, you may also see my (embarrassing and clueless) comments below it. See the second to last paragraph of this answer, here.
 A: For the limit of a composite function you can write
$$
\lim\limits_{x \to a} f(g(x))= \lim\limits_{y\to b} f(y)
$$
under these assumptions:

*

*$\lim\limits_{x \to a} g(x)=b$;

*$b \notin g(U_\delta^*(a))$ for some deleted neighbourhood of $a$, $U_\delta^*(a) := (a-\delta,a)\cup(a,a+\delta)$.

The second condition just says that $g$ send (small) deleted neighbourhoods of $a$ to deleted neighbourhoods of $b$.
To prove the claim above, just apply twice the definition of the limit of a function. (Of course, we interpret the equality above as saying either both limits exist and the equality holds, or they both do not exist.)
You cannot omit the second condition: just consider $g(x):= x \sin \frac1x$ and $f(0):=1$ and $f(x):=0$ otherwise.
The limit on the left does not exist but the limit on the right exists and equals $0$.
To obtain $\lim\limits_{x \to a} f(g(x))=f \left( \lim\limits_{x \to a } g(x) \right)$, you need continuity of $f$. I mean, you could omit it in some special cases but you would not get anything reasonably general.
A: Counterexample:
Let $g$ be the identity function and the limit of it as $x\to 0$ is $0$ and it trivially fulfills your condition. Now take your favorite function $f$ which is discontinuous at $0$ and $\lim\limits_{x\to 0}f(g(x)) $ doesn't exist.
Edit: Actually $f$ has to be a little more than discontinuous, it has to have a jump discontinuity or something like that, such that the limit at $0$ doesn't exist.
