Exploring the Deno Namespace

Exclusive functionality of the Deno namespace

All the functionality not covered by a Web API lives under the Deno namespace. This is functionality exclusive to Deno and that can’t, for instance, be bundled to run in Node.js or the browser.

In this lesson, we’ll explore some of this functionality. We’ll build small utilities, mimicking some of the programs we use daily.

To explore the available functions before we get our hands dirty, they are available on this page of Deno Land.

Building a simple ls command

If you’ve ever used a *nix system’s Terminal or Windows PowerShell, you’re probably familiar with the ls command. Briefly, the ls command lists the files and folders inside a directory. What we’ll do is create a Deno utility that mimics some functionality of ls, that is, lists the files in a directory and shows some details about them.

The original command has a countless number of flags, which we won’t implement here for brevity reasons.

The information we decided to show is the name, size, and last modified file date. Let’s get our hands dirty:

Step 1

Create a file named list-file-names.js, and use Deno.readDir to get a list of all files and folders in the current directory:

Get hands-on with 1200+ tech skills courses.