@dev-crew-berlin/enter-js-utils 0.70.0 → 0.70.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/models/rsvp.d.ts +3 -1
- package/dist/models/rsvp.js +20 -4
- package/package.json +1 -1
package/dist/models/rsvp.d.ts
CHANGED
|
@@ -4,7 +4,9 @@ export declare class Rsvp {
|
|
|
4
4
|
tieBreaker: string;
|
|
5
5
|
time: Date | null;
|
|
6
6
|
personCount: number;
|
|
7
|
-
constructor(
|
|
7
|
+
constructor(args: RsvpJSON | number);
|
|
8
|
+
static confirm(personCount?: number): Rsvp;
|
|
9
|
+
static decline(): Rsvp;
|
|
8
10
|
get confirmed(): boolean;
|
|
9
11
|
toJSON(): RsvpJSON;
|
|
10
12
|
}
|
package/dist/models/rsvp.js
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
1
2
|
export class Rsvp {
|
|
2
|
-
constructor(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
constructor(args) {
|
|
4
|
+
if (typeof args == 'number') {
|
|
5
|
+
this.tieBreaker = uuidv4();
|
|
6
|
+
this.time = new Date();
|
|
7
|
+
this.personCount = args;
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
this.tieBreaker = args.tieBreaker;
|
|
11
|
+
this.time = args.time ? new Date(args.time) : null;
|
|
12
|
+
this.personCount = args.personCount;
|
|
13
|
+
}
|
|
14
|
+
static confirm(personCount = 1) {
|
|
15
|
+
if (personCount < 1) {
|
|
16
|
+
throw new Error('negative person count is not a positive response');
|
|
17
|
+
}
|
|
18
|
+
return new Rsvp(personCount);
|
|
19
|
+
}
|
|
20
|
+
static decline() {
|
|
21
|
+
return new Rsvp(0);
|
|
6
22
|
}
|
|
7
23
|
get confirmed() {
|
|
8
24
|
return this.personCount > 0;
|