My First Deno App: UUID Generator

andyrewlee

Andrew Lee

Posted on May 7, 2020

My First Deno App: UUID Generator

This is a simple script that generates UUIDs and prints to the screen. We can pass in an argument to specify how many UUIDs we want to generate.

import { v4 } from "https://deno.land/std/uuid/mod.ts";
import { parse } from "https://deno.land/std/flags/mod.ts";

const { args } = Deno;
const count = parse(args)._[0] || 1;

for (let i = 0; i < count; i++) {
  const uuid = v4.generate();
  console.log(uuid);
}
Enter fullscreen mode Exit fullscreen mode

We can run this with deno:

deno uuid-gen.ts 3
Enter fullscreen mode Exit fullscreen mode
cb41ae5f-aa37-4f32-b29b-486a06d439fe
93c81358-f372-491b-a683-db66fc104334
f437a7cd-23c4-498e-b10f-2ded65ce0390
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
andyrewlee
Andrew Lee

Posted on May 7, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

My First Deno App: UUID Generator
typescript My First Deno App: UUID Generator

May 7, 2020