• Home
  • Books
  • Node
  • Testing
  • JavaScript
  • More...
  • Search
  • About
  • Gear & Setup

JavaScript

A collection of 104 posts

#javascript #react #vuejs

Detect ctrl/cmd/alt/shift + Click in Vanilla JavaScript, React and Vue.js

Detecting control-click, command-click, meta-click, alt-click and shift-click in JavaScript without listening to keydown events is straightforward. The naive approach is to bind aggressively to key events (keydown, keypress, keyup) and to maintain state of what is currently press ...

  • Hugo Di Francesco
    Author
2 min read
#micro #node #javascript #SQLite

Record analytics events with a Zeit "micro" + SQLite3 Node.js application

micro-analytics-events - A Node.js microservice to record analytics events to SQLite3 with Zeit’s “micro” In order to finally switch off Google Analytics, I need to replace my goal conversion tracking somehow. I’ve got pageview data using Simple Analytics ...

  • Hugo Di Francesco
    Author
11 min read
#jest #javascript #node #testing

How to run Jest tests sequentially

By default Jest runs tests in parallel with a “a worker pool of child processes that run tests” (Jest CLI docs). As per the Jest documentation, running tests in sequence (serially), can be helpful for debugging purposes and for test run performance reasons. ...

  • Hugo Di Francesco
    Author
2 min read
#javascript #node

Detect if the current file/module is the entrypoint or import/require-d in Node.js

How does one identify whether a JavaScript file is being run directly (node file.js) or it’s being import/require-d (require('./file') in another JS file). In Python the pattern leverages the __main__ property in modules like so: if __name__ == '__main__': # do some ...

  • Hugo Di Francesco
    Author
1 min read
#meta #jamstack #hugo #javascript

Add Diagrams to your Jekyll/Hugo/Gatsby blog with Mermaid JS

Add diagrams to your JAMStack (Jekyll/Hugo/Gatsby) blog with Mermaid JS Update 17th January 2024: Hugo now has native hooks for diagrams, so that code-fences using ```mermaid [content]``` can have a custom template, see the Content Management > Diagrams > Mermaid diagrams ...

  • Hugo Di Francesco
    Author
4 min read
#javascript #node #meta

Yarn Workspaces: monorepo management without Lerna for applications and coding examples

How to use Yarn Workspaces to manage applications/coding examples. Lerna isn’t required when you don’t need the git diffing and versioning facilites. What’s more Yarn Workspaces are a great lightweight tool to get up and running faster for simple Node.js monore ...

  • Hugo Di Francesco
    Author
3 min read
#node #lunrjs #hugo #meta #javascript

Add Search to a Hugo site with Lunr.js and Node.js

Hugo “The world’s fastest framework for building websites” is a great option for JAMStack (JavaScript, APIs, prebuild Markup) sites. Lunr.js is “A bit like Solr, but much smaller and not as bright”, it’s a pure JavaScript implementation of a Solr-lik ...

  • Hugo Di Francesco
    Author
5 min read
#javascript

JavaScript Data Type Check Cheatsheet

JavaScript (JS) is a lightweight, interpreted, or just-in-time compiled programming language with first-class functions. MDN Web Docs - javascript Detailed in this post are common JavaScript data type checks, pitfalls and idiomatic workarounds. ...

  • Hugo Di Francesco
    Author
11 min read
#javascript #jest #testing #node

Jest ignore or exclude file/function/statement from test coverage

In computer science, test coverage is a measure used to describe the degree to which the source code of a program is executed when a particular test suite runs. Code coverage - Wikipedia Code coverage is usually used as a quality metric for software eg. “Our code has to have 80% ...

  • Hugo Di Francesco
    Author
4 min read
#node #serverless #javascript #automation #deployment

Super-powered newsletter content with Pocket and Netlify Lambda

An example Netlify Lambda to fetch all “newsletter” posts from Pocket. Pocket is an application and web service for managing a reading list of articles from the Internet. It’s quite widely used and tightly integrated into the Firefox browser. I find that I use it extensive ...

  • Hugo Di Francesco
    Author
5 min read
← Next Posts Page 6 of 11  Previous Posts →

Interested in Alpine.js?

Power up your debugging with the Alpine.js Devtools Extension for Chrome and Firefox. Trusted by over 15,000 developers (rated 4.5 ⭐️).

Install Now close
Code with Hugo
Latest Posts Github