Skip to main content
Module

std/testing/bdd_examples/user.ts

Deno standard library
Go to Latest
File
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.export class User { static users: Map<string, User> = new Map(); age?: number;
constructor(public name: string) { if (User.users.has(name)) { throw new Error(`User ${name} already exists`); } User.users.set(name, this); }
getAge(): number { if (!this.age) { throw new Error("Age unknown"); } return this.age; }
setAge(age: number) { this.age = age; }}