JavaScript code

Converting sharp-recipe-parser from typescript to javascript + jsdoc

Introduction I should start by saying that I am a big proponent of TypeScript. I have been using it since version 1.5 back in 2015. Coming from a backend background with typed languages, not having types in JavaScript was an interesting experience for me. As a developer, the two aspects of typed languages that help me the most are intellisense and the compiler. Intellisense helps me write code faster, and the compiler helps me catch errors before runtime....

January 1, 2024 · 6 min · LPains
Recipe UOMs

Introducing sharp-recipe-parser

For almost four years now, I have maintained the Sharp Cooking app. From the beginning, one of the features I wanted to provide was ingredient UOM conversion. In version 1.4 of the app, a preview of the UOM conversion feature was made available. In this post, I will describe the process and how it was achieved. Before we get into UOM conversion, we first need to break down an ingredient line into its components....

August 5, 2023 · 3 min · LPains
Dirty rugby match

Vue router dirty checking before navigation

Ever filled up a form with a bunch of information and then accidentally navigated away and lost all data? Well, that’s frustrating. However, as a developer, it might be tricky to implement such functionality. This post is a practical guide to implementing is dirty checking using Vue, Vue Router and Typescript. TL;DR Code is available on GitHub. Expected behavior In a Vue app with Vue Router, when a user modifies data in a form and any navigation to another route occurs, the user should be notified and have the ability to cancel navigation....

January 11, 2020 · 2 min · LPains

Simple Vue directive for hotkeys

I’m a fan of hotkeys and I use them for a lot of things. In fact, I believe that 80% of the commands I use in my IDEs (Visual Studio and Visual Studio Code mostly) I use via hotkeys. Nothing is better than CTRL + p in VS Code or CTRL + k + d in VS. Anyway, while a lot of users really don’t care about that, those that have data entry intensive use cases will probably appreciate some forethought in hotkeys in the apps they use....

July 26, 2019 · 2 min · LPains

Tips and tricks for vue with typescript

I’ve been working on a vue project with typescript for almost a year now. Along the way, we found a few little things that I would like to share. Everything shown here is buried in vue’s documentation somewhere, you may need to dig a little, but it is all there. Note that all examples below use single file components and typescript 3. The project was created using vuecli 3. #1 typing $store and $refs in vue component When using the $store or $refs in a component, there is no typing available due to how vue wire the component together....

June 23, 2019 · 3 min · LPains