12345678910111213141516 |
- /// <reference path="../Say.ts" />
- class SayIf extends Say {
- private condition : () => boolean;
- public constructor (condition : () => boolean, ...objs : Array<any>) {
- super(...objs);
- this.condition = condition != undefined ? condition : () => { return true; };
- }
- public async getPureElements () : Promise<Array<Element | Text>> {
- if (this.condition()) {
- let paragraphs = await this.getParagraphs();
- return paragraphs.length == 1 ? paragraphs[0] : Array.prototype.concat.apply([], paragraphs);
- }
- return [];
- }
- }
|