DEV Community

Andrew Lee
Andrew Lee

Posted on

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

Top comments (0)