angular-package
TwitterGitHub
Wrapper
Wrapper
  • Introduction
  • ❤ Benefits
    • Explanation
    • Designing
  • General concepts
  • Getting started
    • Skeleton
    • Installation
      • npm
    • Public API
    • Basic concepts
  • Wrap {}
    • Overview
    • Generic type variables
    • ★ Constructor
    • Accessors
      • closing
      • opening
      • text
      • [Symbol.toStringTag]
    • Properties
      • #closing
      • #opening
      • #text
    • Methods
      • Static
        • hasClosing()
        • hasOpening()
        • isWrap()
      • Instance
        • getClosing()
        • getOpening()
        • getText()
        • hasClosing()
        • hasOpening()
        • hasText()
        • isWrapped()
        • ★ replaceClosing()
        • ★ replaceOpening()
        • ★ replaceText()
        • toString()
        • valueOf()
    • Example usage
  • Wrapper {}
    • Overview
    • Generic type variables
    • Constructor
    • Accessors
      • [Symbol.toStringTag]
    • Methods
      • Static
        • define()
        • isWrapper()
        • replaceClosing()
        • replaceOpening()
        • unwrap()
      • Instance
        • isClosingIn()
        • isOpeningIn()
        • replaceClosingIn()
        • replaceOpeningIn()
        • removeWrapIn()
        • textReplaceClosing()
        • textReplaceOpening()
        • ⚠ textHasClosing()
        • ⚠ textHasOpening()
        • textUnwrap()
        • textWrap()
        • toArray()
        • toWrap()
        • unwrap()
        • unwrapText()
        • ★ wrap()
        • ★ wrapOn()
        • ★ wrapText()
    • Example usage
  • Type
    • Wrapped
  • Change log
    • Keep a changelog
    • CHANGELOG.md
    • v1.0.0
  • GIT
    • Commit
    • Semantic Versioning
  • License
    • MIT
  • Contact
    • ⋯ Chat
    • @ Email
  • Donate
    • ฿ Cryptocurrency
    • $ Fiat
  • More versions
Powered by GitBook
On this page
  • Wrap.prototype.isWrapped()
  • Parameters
  • Returns
  • Example usage
  • Basic
  • Given opening
  • Given closing
  • Given opening and closing chars

Was this helpful?

  1. Wrap {}
  2. Methods
  3. Instance

isWrapped()

PrevioushasText()Next★ replaceClosing()

Last updated 3 years ago

Was this helpful?

Wrap.prototype.isWrapped()

The method checks whether the of the specified object is wrapped by the and chars of an instance or given and chars.

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

wrap.class.ts
public isWrapped(
  opening: string = this.#opening,
  closing: string = this.#closing
): boolean {
  return this.hasOpening(opening) && this.hasClosing(closing);
}

Parameters

opening: string = this.#opening

Optional opening chars of a type to check if the contains them at the beginning. The default value is picked from the private property of an instance.

closing: string = this.#closing

Optional closing chars of a type to check if the contains them at the end. The default value is picked from the private property of an instance.

Returns

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

// 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

// 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

// 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('', '');

The return value is a indicating whether the object has both and chars or given and chars.

primitive value
opening
closing
string
primitive value
#opening
string
primitive value
#closing
opening
closing
boolean
opening
closing
opening
closing