froebel
Version:
TypeScript utility library
13 lines (12 loc) • 450 B
TypeScript
import { IsEvenLength, Surround } from "./types";
/**
* Surrounds the `str` with `surrounding`. `surrounding` must have an even length.
*
* @example
* ```
* surround("foo", "()") // "(foo)"
* surround("foo", "({[]})") // "({[foo]})"
* ```
*/
export declare const surround: <A extends string, B extends string>(str: A, surrounding: B) => B extends "" ? A : IsEvenLength<B> extends true ? Surround<A, B> : never;
export default surround;