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.