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.hasOpening()
  • Parameters
  • Returns
  • Example usage

Was this helpful?

  1. Wrap {}
  2. Methods
  3. Static

hasOpening()

PrevioushasClosing()NextisWrap()

Last updated 3 years ago

Was this helpful?

Wrap.hasOpening()

Checks whether the has given chars at the beginning.

wrap.class.ts
public static hasOpening(text: string, opening: string): boolean {
  return (
    typeof text === 'string' &&
    text.length >= 1 &&
    typeof opening === 'string' &&
    opening.length >= 1 &&
    text.slice(0, opening.length) === opening
  );
}

Parameters

text: string

The text of , to check whether it contains given chars.

opening: string

The opening chars of to check if a given contains.

Returns

Example usage

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

const quote = new Wrap(`[`, `]`, 'quote');

// Returns true.
Wrap.hasOpening(quote.valueOf(), '[');

// Returns false.
Wrap.hasOpening(quote.valueOf(), '>');

// Returns false.
Wrap.hasOpening(quote.valueOf(), '');

// Returns false.
Wrap.hasOpening(new Wrap(``, `]`, 'quote').valueOf(), '');

The return value is a indicating whether the contains chars at the beginning.

string
string
text
opening
opening
text
boolean
text
opening