isWrapped()
Wrap.prototype.isWrapped()
Wrap.prototype.isWrapped()The method checks whether the primitive value of the specified object is wrapped by the opening and closing chars of an instance or given opening and closing chars.
public isWrapped(
opening: string = this.#opening,
closing: string = this.#closing
): boolean {
return this.hasOpening(opening) && this.hasClosing(closing);
}Parameters
opening: string = this.#opening
opening: string = this.#openingOptional opening chars of a string type to check if the primitive value contains them at the beginning. The default value is picked from the private #opening property of an instance.
closing: string = this.#closing
closing: string = this.#closingOptional closing chars of a string type to check if the primitive value contains them at the end. The default value is picked from the private #closing property of an instance.
Returns
The return value is a boolean indicating whether the object has both opening and closing chars or given opening and closing chars.
Example usage
Basic
// Example usage.
import { Wrap } from '@angular-package/wrapper';
// Returns true. Checks `[]`.
new Wrap(`[`, `]`, 'quote').isWrapped();
// Returns false.
// It's not wrapped cause of opening chars are an empty string.
new Wrap(``, `]`, 'quote').isWrapped();
// Returns false.
// It's not wrapped cause of closing chars are an empty string.
new Wrap(`[`, ``, 'quote').isWrapped();
// Returns false.
new Wrap(``, ``, 'quote').isWrapped();Given opening
opening// Example usage.
import { Wrap } from '@angular-package/wrapper';
// Returns true. Checks `[]`.
new Wrap(`[`, `]`, 'quote').isWrapped('[');
// Returns false.
new Wrap(`[`, `]`, 'quote').isWrapped('[', '');
// Returns false. Checks `<]`.
new Wrap(`[`, `]`, 'quote').isWrapped('<');
// Returns false.
// It's not wrapped cause of opening chars are an empty string.
new Wrap(``, `]`, 'quote').isWrapped('<');
// Returns false.
// It's not wrapped cause of closing chars are an empty string.
new Wrap(`[`, ``, 'quote').isWrapped('[');
// Returns false.
// It's not wrapped cause of closing chars are an empty string.
new Wrap(`[`, ``, 'quote').isWrapped('[', ''),Given closing
closing// Example usage.
import { Wrap } from '@angular-package/wrapper';
// Returns true. Checks `[]`.
new Wrap(`[`, `]`, 'quote').isWrapped(undefined, ']');
// Returns false. Checks `[>`.
new Wrap(`[`, `]`, 'quote').isWrapped(undefined, '>');
// Returns false.
// It's not wrapped cause of opening chars are an empty string.
new Wrap(``, `]`, 'quote').isWrapped(undefined, ']');
// Returns false.
// It's not wrapped cause of opening chars are an empty string.
new Wrap(``, `]`, 'quote').isWrapped(``, ']');Given opening and closing chars
opening and closing chars// Example usage.
import { Wrap } from '@angular-package/wrapper';
// Returns false.
new Wrap(`[`, `]`, 'quote').isWrapped('[', ']');
// Returns false.
new Wrap(`[`, `]`, 'quote').isWrapped('[', '>');
// Returns false.
new Wrap(`[`, `]`, 'quote').isWrapped('<', ']');
// Returns false.
new Wrap(`[`, `]`, 'quote').isWrapped('<', '>');
// Returns false.
new Wrap(``, ``, 'quote').isWrapped('', '');Last updated
Was this helpful?