Good day my fabulous readers and I hope all is well with you. I just got back from speaking at the excellent Devnexus event and despite some travel issues (thank you storms, really), I had a great time. I got to see not one, not two, but three very old friends of mine and attended some good sessions as well. I'm home for a week and then on the road again to the Adobe ColdFusion Summit in the DC area. Don't forget, this Tuesday I've got another episode of <Code><Br>
coming up. I'll be building, or attempting to, build a PWA live. Surely it will go perfectly, right?
Pretty Console Table Printing
First up is a neat little library, voici.js, that makes it a bit easier to print tabular data in the console. I'm going to borrow from their quick start to show you an example:
import { Table } from 'voici.js'
const data = [
{ firstname: 'Homer', lastname: 'Simpson', age: 39 },
{ firstname: 'Marge', lastname: 'Simpson', age: 36 },
{ firstname: 'Bart', lastname: 'Simpson', age: 10 },
{ firstname: 'Lisa', lastname: 'Simpson', age: 8 },
{ firstname: 'Maggie', lastname: 'Simpson', age: 1 }
];
const table = new Table(data);
table.print();
Given the above code, you'll get this in your terminal:
You can get pretty fancy too, for example, easily picking out what columns to show, and even creating 'virtual' columns based on custom logic. If you want to see an example of how I used this recently, read my recent post on how I investigated some odd traffic issues on my site.
A Great Example of Promise.race
Earlier this year I took a look at various Promise methods, including Promise.race
. In this post by David Bushel, he demonstrates how he used Promise.race
to nicely handle an interesting use case with media files. It's a perfect example of how useful this Promise
method can be.
Speaking of Promises...
While on the topic of Promises, Lydia Hallie has a dang good and deep look at how Promises work: JavaScript Visualized: Promise Execution. She goes into incredible depth about how the internals of Promises operator and honestly, a lot of this was new to me. She also built some incredibly good visualizations. I will say I'm not a fan of animated GIFs - it's sometimes difficult to tell when the 'loop' is starting and I wish I could pause - but the ones used here are pretty well built. Be sure to check out her blog as a quick look at her past entries shows a wealth of valuable information.
And last but not least...
In my last post, I shared a music video from a recent Spotify discovery, so I figured why not do it again? Enjoy!