Categories
javascript typescript

How to achieve validatedNel with fp-ts

fp-ts is a great library, but it can be confusing some times. The last problem that I had was that I didn’t know how to implement validatedNel. Some methods have been deprecated, and the issue answers also didn’t help. ValidatedNel validatedNel is used to validate multiple problems and then merge them together into a single […]

Categories
javascript

Lazy/conditional logging in JavaScript

I had some trace logs that I only wanted to enable conditionally, eg only when the logging level was set to TRACE. I couldn’t find a node.js library that enables this kind of logging. For each of them, the logger always evaluated the string input. The longRunningTask was always ran, even if trace logging was […]

Categories
javascript

How to scroll to line with codemirror-react

This is for “@uiw/react-codemirror”: “^4.20.2” capture the ref to the codemirror objects 2. on each new ref callback, call the dispatch with the new selection and scrollIntoView note: I used MUI accordion, and for that the useRef didn’t seem to update when I collapsed and expanded the Accordion. Therefore I needed to update the object […]