Skip to content

Commit

Permalink
chore: add nodejs inspect to explain correct properties (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
gutyerrez authored Jan 2, 2024
1 parent b3beda1 commit 968e1db
Show file tree
Hide file tree
Showing 13 changed files with 202 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/data/Body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ export class Body {

return record;
}

[Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {
return this.toJSON();
}
}
62 changes: 62 additions & 0 deletions src/data/Contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,44 @@ export class Contact {
public get urls(): ContactUrl | undefined {
return this.#urls;
}

public toJSON(): Record<string, unknown> {
const record: Record<string, unknown> = {};

if (this.#addresses) {
record['addresses'] = this.#addresses;
}

if (this.#birthday) {
record['birthday'] = this.#birthday;
}

if (this.#emails) {
record['emails'] = this.#emails;
}

if (this.#name) {
record['name'] = this.#name;
}

if (this.#org) {
record['org'] = this.#org;
}

if (this.#phones) {
record['phones'] = this.#phones;
}

if (this.#urls) {
record['urls'] = this.#urls;
}

return record;
}

[Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {
return this.toJSON();
}
}

export class ContactAddress {
Expand Down Expand Up @@ -169,6 +207,10 @@ export class ContactAddress {

return record;
}

[Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {
return this.toJSON();
}
}

export class ContactEmail {
Expand Down Expand Up @@ -204,6 +246,10 @@ export class ContactEmail {

return record;
}

[Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {
return this.toJSON();
}
}

export class ContactName {
Expand Down Expand Up @@ -289,6 +335,10 @@ export class ContactName {

return record;
}

[Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {
return this.toJSON();
}
}

export class ContactOrg {
Expand Down Expand Up @@ -337,6 +387,10 @@ export class ContactOrg {

return record;
}

[Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {
return this.toJSON();
}
}

export class ContactPhone {
Expand Down Expand Up @@ -385,6 +439,10 @@ export class ContactPhone {

return record;
}

[Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {
return this.toJSON();
}
}

export class ContactUrl {
Expand Down Expand Up @@ -420,4 +478,8 @@ export class ContactUrl {

return record;
}

[Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {
return this.toJSON();
}
}
4 changes: 4 additions & 0 deletions src/data/Context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ export class Context {

return record;
}

[Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {
return this.toJSON();
}
}
4 changes: 4 additions & 0 deletions src/data/Currency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ export class Currency {

return record;
}

[Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {
return this.toJSON();
}
}
12 changes: 12 additions & 0 deletions src/data/DateTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export class DateTime {

return record;
}

[Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {
return this.toJSON();
}
}

export class DateTimeComponent {
Expand Down Expand Up @@ -125,6 +129,10 @@ export class DateTimeComponent {

return record;
}

[Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {
return this.toJSON();
}
}

export class DateTimeEpoch {
Expand All @@ -145,4 +153,8 @@ export class DateTimeEpoch {

return record;
}

[Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {
return this.toJSON();
}
}
4 changes: 4 additions & 0 deletions src/data/Footer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ export class Footer {

return record;
}

[Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {
return this.toJSON();
}
}
20 changes: 20 additions & 0 deletions src/data/Header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export class Header {

return record;
}

[Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {
return this.toJSON();
}
}

export class HeaderProvider {
Expand All @@ -90,6 +94,10 @@ export class HeaderProvider {

return record;
}

[Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {
return this.toJSON();
}
}

export class HeaderImage {
Expand Down Expand Up @@ -140,6 +148,10 @@ export class HeaderImage {

return record;
}

[Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {
return this.toJSON();
}
}

export class HeaderVideo {
Expand Down Expand Up @@ -190,6 +202,10 @@ export class HeaderVideo {

return record;
}

[Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {
return this.toJSON();
}
}

export class HeaderDocument {
Expand Down Expand Up @@ -253,4 +269,8 @@ export class HeaderDocument {

return record;
}

[Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {
return this.toJSON();
}
}
Loading

0 comments on commit 968e1db

Please sign in to comment.