🦕 Running your first Deno script

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • SonarLint - Clean code begins in your IDE with SonarLint
  • Scout APM - Less time debugging, more time building
  • SaaSHub - Software Alternatives and Reviews
  • Hacker News API

    Documentation and Samples for the Official HN API (by HackerNews)

    Since we will interact with the Hacker News API, let's clear the main.ts file and define the baseURL variable as follows:

  • TypeScript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    Modern: Deno is built with modern technologies and follows a modern philosophy; it natively supports TypeScript and ES modules; it doesn't require a centralized package management solution; it also provides useful developer tools out of the box such as an opinionated source code formatter and a testing framework

  • SonarLint

    Clean code begins in your IDE with SonarLint. Up your coding game and discover issues early. SonarLint is a free plugin that helps you find & fix bugs and security issues from the moment you start writing code. Install from your favorite IDE marketplace today.

  • node

    Node.js JavaScript runtime :sparkles::turtle::rocket::sparkles:

    In this post, we are going from zero to running a small but nontrivial script that fetches comments from Hacker News in real time using Deno, a new runtime for JavaScript and TypeScript created by Ryan Dahl, the original creator of Node.js.

  • deno

    A modern runtime for JavaScript and TypeScript.

    // main.ts import { sleep } from "https://deno.land/x/sleep/mod.ts"; // ... async function streamComments() { let id = await getMaxItemID(); while (true) { const item = await getItemByID(id); if (!item) { await sleep(5); continue; } // Print only items that are visible comments const { type, deleted, dead } = item; const removed = deleted || dead || false; if (type === "comment" && !removed) { // Get the comment's author, if any const author = item.by ?? "unknown author"; // Get the comment's URL on HN website const hnURL = `https://news.ycombinator.com/item?id=${id}`; // Print the comment console.log(`\nRead new comment by ${author} on ${hnURL}`); console.log(item); } id += 1; } }

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts