#javascript

`array.filter` with `async/await`

I can never remember how to filter arrays in JavaScript when I need to use await to run a method.

Map object values .toLowerCase()

I recently needed to make sure that all of the values in an object were lower case. If I were dealing with an array I could have used map like so:

Ensure all nock mock interceptors are used

When using nock to mock HTTP requests in node, you can call nock.disableNetConnect() to make nock throw an error any time a request is made that does not have a mock configured. This is useful, but …

Find value of key recursively with JavaScript

Here’s a snippet that will allow you to find the values in the key demo no matter where in an object it’s stored. It recursively searches, and includes objects embedded in lists

Fetch all pages with Octokit pagination

A quick one today as I constantly need to fetch more than 100 results from the GitHub API using Octokit and always end up digging in to an old project to copy out this code snippet.

Mock require with Jest

I needed to mock a call to require that was used to parse a JSON file and return the data. The require was only called if a value wasn't provided as a parameter and it needed to load a default from …

Create a GitHub Action using actions-toolkit

In this post we're going to create a GitHub action that outputs an emoji when triggered by a release. It'll output 🎉 if a release is created, ☠️ if it's deleted and ⚠️ if it's any other action.

Google OAuth with Node.js

I've been working on an Alexa skill that needed access to my Google Calendar account. The provided quick start is a little tough to follow, so I worked through it and created a minimal example that …

Using an Amazon Dash Button with NodeJS

I finally picked up an Amazon Dash Button to see how they can be used. Here's how to interact with one via node.js.

Force flush headers using the HTTP module for NodeJS

Although it's not something that you'll commonly want to do, today I found myself wanting to flush HTTP headers immediately without sending any additional data with them. Internally, NodeJS won't …

Debugging NodeJS Memory Leaks

I recently had the (mis?)fortune of trying to reproduce a memory leak in a NodeJS project I've been working on. I started out by searching for nodejs memory leak and having a read of the tools that …