Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/froebel/surround.ts>surround

A strictly typed utility library.
Go to Latest
variable surround
import { surround } from "https://deno.land/x/froebel@v0.18.0/surround.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