-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Balte de Wit
committed
Sep 21, 2019
1 parent
e7c47d4
commit bc05045
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { NamedMessage } from '../message' | ||
import { AbstractCommandNoResponse } from './abstractCommand' | ||
|
||
export class GoToCommand extends AbstractCommandNoResponse { | ||
clip?: string | ||
clipId?: number | ||
timecode?: string | ||
|
||
constructor (clip?: string, clipId?: number, timecode?: string) { | ||
super() | ||
|
||
this.clip = clip | ||
this.clipId = clipId | ||
this.timecode = timecode | ||
} | ||
|
||
serialize () { | ||
const res: NamedMessage = { | ||
name: 'goto', | ||
params: {} | ||
} | ||
|
||
if (this.clip !== undefined) res.params.clip = this.clip | ||
if (this.clipId !== undefined) res.params.clipId = this.clipId + '' | ||
if (this.timecode !== undefined) res.params.timecode = this.timecode | ||
|
||
if (Object.keys(res.params).length === 0) { | ||
throw new Error('GoToCommand needs at least one parameter') | ||
} else if (Object.keys(res.params).length > 1) { | ||
throw new Error('GoToCommand should have at most one parameter') | ||
} | ||
|
||
return res | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters