Fancy hap show, include part in snapshots (#291)

* fix _mod import

* prettier hap show, use both whole and parts in snapshots, rebuild snapshots
This commit is contained in:
Alex McLean 2022-12-10 10:56:16 +00:00 committed by GitHub
parent f827201ee0
commit 98e9780819
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 13601 additions and 13576 deletions

View file

@ -79,9 +79,34 @@ export class Hap {
);
}
show() {
show(compact = false) {
const value = typeof this.value === 'object'
? compact
? JSON.stringify(this.value).slice(1, -1).replaceAll('"', '').replaceAll(',', ' ')
: JSON.stringify(this.value)
: this.value
var spans = '';
if (this.whole == undefined) {
spans = '~' + this.part.show;
}
else {
var is_whole = this.whole.begin.equals(this.part.begin) && this.whole.end.equals(this.part.end);
if (!this.whole.begin.equals(this.part.begin)) {
spans = this.whole.begin.show() + ' ⇜ ';
}
if (!is_whole) {
spans += '(';
}
spans += this.part.show();
if (!is_whole) {
spans += ')';
}
if (!this.whole.end.equals(this.part.end)) {
spans += ' ⇝ ' + this.whole.end.show()
}
}
return (
'(' + (this.whole == undefined ? '~' : this.whole.show()) + ', ' + this.part.show() + ', ' + this.value + ')'
'[ ' + spans + ' | ' + value + ' ]'
);
}

View file

@ -110,7 +110,7 @@ export class TimeSpan {
}
show() {
return this.begin.show() + ' -> ' + this.end.show();
return this.begin.show() + ' ' + this.end.show();
}
}