Skip to main content
Module

x/froebel/string.ts>surround

A strictly typed utility library.
Go to Latest
variable surround
import { surround } from "https://deno.land/x/froebel@v0.21.0/string.ts";

Surrounds the str with surrounding. surrounding must have an even length.

Examples

Example 1

surround("foo", "()")      // "(foo)"
surround("foo", "({[]})")  // "({[foo]})"

type

<A extends string, B extends string>(str: A, surrounding: B) => B extends "" ? A : IsEvenLength<B> extends true ? Surround<A, B> : never