Deno differentiates itself with some unique features like:
Undoubtedly, JSON Web Token (JWT) is one of the most popular mechanisms to verify that the possessor of the token is authentic and can be given access to the resources (of course as allowed by permissions/roles/etc.). JWT is an internet standard that’s published in RFC 7519 https://datatracker.ietf.org/doc/html/rfc7519. JWT is also very popular for SSO applications due to its low overhead.
In this article, we’ll go over how to generate and verify JWT in Deno using standard library only. There is a very popular module called djwt (https://github.com/timonson/djwt) that is widely used to work with JWT. However, for better understanding of…
Some applications have a need to process a directory recursively i.e. every file present in a given directory structure. For example — an application may need to process all the .xls files present in an extracted zip file that could result in a complex directory structure. The .xls files could be present in root directory, or inside other directories under root directory. The same could get extended to processing all document type of files like .doc, .xls, .pdf, etc.
Deno’s standard library’s fs module comes with a powerful generator function walk/walkSync to process a directory recursively. …
Streams are a one of the commonly used data structures for chunked handling of a large amount of flowing data. The primary motivation behind using streams is to process a large volume of data in chunks without increasing memory pressure. They key is volume and chunks.
For example — a large file (say 5G) should be read/processed in chunks rather than loading it completely in memory and having a spike in the process’s memory usage.
The web standards support readable, writable, transformable streams for handling data like files, media, HTTP request/response bodies, etc.
Reader & Writer
Since it’s inception…
Deno’s core runtime comes with support for TCP and UDP. The underlying TCP connection is already being used by HTTP and WebSocket. While, the UDP handling is still under the unstable umbrella, and is expected to get vetted very soon (perhaps from Deno 2.0).
For a quick background, TCP requires a prior connection establishment before data could be exchanged. TCP has reliability and security built-in. UDP is a stateless protocol and there is no connection required before sending data. There are no guarantees for message delivery either. …
Buffers are one of the commonly used data structures in programming. A buffer is an in-memory storage of any data. In Deno, buffers are variable sized i.e. they can grow as needed. This makes the buffers attractive for unknown/variable sized data handling. Deno’s buffers expand themselves as more data is added to them. Deno’s buffers implements
write functions, thereby making them compatible with
In this article, we’ll go over the basics of Deno’s buffers, some useful functions, and using them for/as
From release 2.0, Deno would move the buffers to…
console.log gets primarily used for logging any data on the console. Undoubtedly,
console.log would be the most popular logging function. It’s flexible too as it can log any kind of data. But console logging isn’t limited to
console.log . There are a lot more functions to log on console, some of them quite useful for certain use cases.
The Web Hypertext Application Technology Working Group (whatwg) has a living standard for advanced console logging (https://console.spec.whatwg.org/). As Deno follows the web standards wherever possible, Deno implements all the functionality proposed in the console specification.
In this article, we’ll go…
Deno’s core runtime supports web’s standard performance APIs to do any performance related measurements. Deno supports user timing level 3 APIs proposed in W3C’s specification: https://w3c.github.io/user-timing. With these APIs, developers get access to high precision timestamps that would be useful in baselining, measuring, and comparing any piece of code.
There is a nice documentation of the performance APIs here: https://developer.mozilla.org/en-US/docs/Web/API/Performance. Rather than rewriting the documentation, in this article, we’ll focus on using these APIs in Deno. We’ll go over creating performance marks and measures in Deno. Also, we’ll compare performance APIs with console.time/timeEnd API.
It’s very important to note that…
Deno treats all the input/output i.e. standard input/output, files, sockets, etc. as resources. There is a simple incrementing resource ID allocated whenever a resource is opened. To make application cleaner and consistent, it’s important for Deno to have a consistent interface for accessing resources regardless of the type of the resource.
For example — from an application point of view, getting data from a file should not be different from getting data from stdin. If the interface is tied to the resource, then applications would get inconsistent too. The code would be tough to read and tougher to maintain.
fmt command is very simple to use as it doesn’t have any customization options. In other words,
fmt formats code in a pre-defined format. There is no way to customize tab stop, braces, indentation, etc.
It’s important to note that the
fmt command overwrites the source files. This shouldn’t be…
Mayank has more than 17 years of software experience, with last few years in developing high performance production grade microservices in Node.js.