Static methods

The static methods of `Wrap` the string object.

Public

Wrap.isWrap()

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

wrap.class.ts
public static isWrap<Opening extends string, Closing extends string>(
  value: any,
  opening?: Opening,
  closing?: Closing
): value is Wrap<Opening, Closing> {
  return isInstance(value, Wrap)
    ? isStringType(opening) && isStringType(closing)
      ? opening === value.opening && closing === value.closing
      : isStringType(opening)
      ? opening === value.opening
      : isStringType(closing)
      ? closing === value.closing
      : true
    : false;
}
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 wrap indicates the Opening type of the Wrap instance via 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 wrap indicates the Closing type of the Wrap instance via the 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

An optional wrap opening to check if the given value contains.

closing?: Closing

An optional wrap closing to check if the given value contains.

Returns

Return type

value is Wrap<Opening, Closing>

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

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

Example usage

Wrap.template()

The static "tag" method builds the wrap of a stringarrow-up-right type on the template. With the added string before the expressions, it returns a wrapped string.

Parameters

Name: type
Description

template: TemplateStringsArray

An array of string values where the first element is a text between opening and closing.

...values: string[]

A rest parameter of expressions, where the first element is the opening and the second is the closing of the wrap.

Returns

The return value is a stringarrow-up-right the wrap, or an empty string if elements of the provided values are not string.

Example usage

Last updated