hasText()
Wrap.prototype.hasText()
Wrap.prototype.hasText()
The method checks whether the text
of a specified Wrap
object is defined, which means it's a string
of at least one char and optionally equal to the given text
.
public hasText(text?: string): boolean {
return (
this.#text.length >= 1 &&
(typeof text === 'string' ? this.#text === text : true)
);
}
Parameters
text
?: string
text
?: string
Optional text of string
type to check whether it's equal to the text
of the Wrap
object.
Returns
The return value is a boolean
indicating whether the text
is defined and optionally equal to the given text
.
Example usage
// Example usage.
import { Wrap } from '@angular-package/wrapper';
// Returns true.
new Wrap(`[`, `]`, 'quote').hasText();
// Returns false.
new Wrap(`[`, `]`).hasText();
// Returns false.
new Wrap(`[`, `]`, '').hasText();
Given text
text
// Example usage.
import { Wrap } from '@angular-package/wrapper';
// Returns true.
new Wrap(`[`, `]`, 'quote').hasText('quote');
// Returns false.
new Wrap(`[`, `]`, '').hasText('');
Last updated
Was this helpful?