deno.land / std@0.166.0 / testing / bdd_examples / user.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// 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 Deno.errors.AlreadyExists(`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; }}
std

Version Info

Tagged at
a year ago