hasClosing()

Wrap.prototype.hasClosing()

Checks whether the primitive value of a specified object has the closing chars or given closing chars.

If given closing chars in the constructor are the empty string, the method returns false.

wrap.class.ts
public hasClosing(closing?: string): boolean {
  return (
    this.#closing.length >= 1 &&
    (typeof closing === 'string' ? this.#closing === closing : true)
  );
}

Parameters

closing?: string

Optional closing chars of a string type to check whether the primitive value contains them at the end.

Returns

The return value is a boolean indicating whether the primitive value has the closing chars or given closing chars.

Example usage

// Example usage.
import { Wrap } from '@angular-package/wrapper';

// Returns true.
new Wrap(`[`, `]`, 'quote').hasClosing();

// Returns false.
new Wrap(`[`, ``, 'quote').hasClosing();

Given closing chars

// Example usage of given closing chars.
import { Wrap } from '@angular-package/wrapper';

// Returns true.
new Wrap(`[`, `]`, 'quote').hasClosing(']');

// Returns false.
new Wrap(`[`, `]`, 'quote').hasClosing('');

// Returns false.
new Wrap(`[`, ``, 'quote').hasClosing('');

// Returns false.
new Wrap(`[`, ``, 'quote').hasClosing(']');

Last updated