Skip to content

Commit

Permalink
feat(ClassConstructorParser): add toString method (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
RealShadowNova committed Sep 16, 2022
1 parent 59c0e02 commit 3f3d08c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/lib/structures/class-parser/ClassConstructorParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,25 @@ export class ClassConstructorParser extends Parser {
};
}

/**
* Converts this parser to a string representation.
* @since 4.0.0
* @returns The string representation of this parser.
*/
public toString(): string {
return ClassConstructorParser.formatToString(this);
}

/**
* Generates a string representation of the given {@link ClassConstructorParser} instance.
* @since 4.0.0
* @param parser The parser to generate the string representation of.
* @returns The string representation of the given parser.
*/
public static formatToString = (parser: ClassConstructorParser): string => {
return `new ${parser.parent.name}(${parser.parameters.map((parameter) => parameter.name).join(', ')})`;
};

/**
* Generates a new {@link ClassConstructorParser} instance from the given data.
* @since 1.0.0
Expand Down

0 comments on commit 3f3d08c

Please sign in to comment.