Browsed by
Tag: Node.js

Posts

Debugging AVA with VS Code is not that simple

Debugging AVA with VS Code is not that simple

In general, I strongly dislike debugging in Visual Studio Code, because it is a pain in the ass to configure for every project from the beginning, besides it sometimes simply doesn’t work.

One of the worst things to debug are unit tests running in Node.js. They run in weird threads, start with complicated frameworks, and often simply don’t hit breakpoints.

The worst so far was AVA.

Read More Read More

Creating an npm package

Creating an npm package

Most of my Node.js projects require some build routine. As a fan of minimalism, for simple builds I used to write short scripts operating directly on fs. In order to avoid duplication and simplify the process for future, I created a simple npm package. I described the required steps below.

Read More Read More

Custom build script in Node.js

Custom build script in Node.js

For simple build tasks in Node.js I use a custom script. Let’s consider the following requirements:

  1. Create the dist and dist/assets folders.
  2. Concatenate several JavaScript files and save to dist/background-dist.js.
  3. Copy assets/*.png files to dist/assets/.
  4. Copy several other files.

Read More Read More

Programming paradigms in JavaScript – callbacks, Promise, async/await, promisify, functional Ramda and reactive RxJS

Programming paradigms in JavaScript – callbacks, Promise, async/await, promisify, functional Ramda and reactive RxJS

As a quick exercise, I wanted to read all URLs from my page’s sitemap instead of crawling the site. Just after I added a nested callback I decided to apply the Single Responsibility Principle and convert calls to Promises. Later I experimented with async/await and automatic conversion with Node’s promisify. Finally, I rewrote the solution in functional style using Ramda and reactive using RxJS. Read on to follow the evolution of callbacks in JavaScript.

Read More Read More