-
Notifications
You must be signed in to change notification settings - Fork 19
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
1 parent
6dc47bc
commit 29350ab
Showing
2 changed files
with
40 additions
and
2 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,28 @@ | ||
import { Generator } from '../interfaces'; | ||
|
||
class CommonGenerator implements Generator { | ||
private name: String; | ||
Check failure on line 4 in src/lib/mock-observations/helpers/CommonGenerator.ts GitHub Actions / build
|
||
private generateObject: Object; | ||
|
||
initialise(name: String, config:Object): void { | ||
this.name = this.validateName(name); | ||
// TODO PB -- validate config is not null, not empty and a valid yml object, use yaml.parse(input) | ||
// TODO PB -- object immutabilty - copy by value here | ||
this.generateObject = config; | ||
} | ||
|
||
next(historical: Object[]): Object { | ||
// TODO PB -- object immutabilty - copy by value here | ||
return this.generateObject | ||
} | ||
|
||
private validateName(name: String | null): String { | ||
if (name === null || name.trim() === '') { | ||
// TODO PB - custom / more specific error? | ||
throw new Error('name is empty or null'); | ||
} | ||
return name; | ||
} | ||
} | ||
|
||
export default CommonGenerator; |
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