Static methods

The static methods of `Wrap` the string object.

Public

Wrap.hasClosing()

Checks whether the text has given closing chars at the end.

wrap.class.ts
public static hasClosing(text: string, closing: string): boolean {
  return (
    isStringLength(text, { min: 1 }) &&
    isStringLength(closing, { min: 1 }) &&
    text.slice(-closing.length) === closing
  );
}

Parameters

Name: type
Description

text: string

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

closing: Closing

The closing chars of string type to check if a given text contains.

Returns

The return value is a booleanarrow-up-right indicating whether the text contains closing chars at the end.

Functions used

isStringLength()

Example usage

Wrap.hasOpening()

Checks whether the text has opening chars at the beginning.

Parameters

Name: type
Description

text: string

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

opening: Opening

The opening chars of string to check if a given text contains.

Returns

The return value is a booleanarrow-up-right indicating whether the text contains opening chars at the beginning.

Functions used

isStringLength()

Example usage

Wrap.isWrap()

The method checks whether the value of any type is the Wrap instance of any or given opening and closing chars.

Generic type variables

Opening extends string

A generic type variable constrained by the stringarrow-up-right, by default of the value captured from the provided opening indicates the Opening type of the Wrap instance the return type.

Closing extends string

A generic type variable constrained by the stringarrow-up-right, by default of the value captured from the provided closing indicates the Closing type of the Wrap instance via return type.

Text extends string A generic type variable constrained by the stringarrow-up-right, by default of the value captured from the provided text indicates the Text type of the Wrap instance via return type.

Parameters

Name: type
Description

value: any

The value of any type to test against the Wrap instance of any or given opening and closing.

opening?: Opening

Optional opening chars of a generic type variable Opening to check if the given value contains.

closing?: Closing

Optional closing chars of a generic type variable Closing to check if the given value contains.

text?: Text

An optional text of a generic type variable Text to check if the given value contains.

Returns

Return type

value is Wrap<Opening, Text, Closing>

The return type is a boolean indicating the value parameter is an instance of Wrap that takes a generic type variable Opening Text and Closing.

The return value is a booleanarrow-up-right type indicating whether the value is an instance of Wrap of any, or the given opening, closing, and text.

Functions used

isStringType(), isInstance()

Example usage

Last updated