Function unwrap

'Unwraps' a string, removing one or more 'wrapper' strings that it starts and ends with. Only removes when a matching end is found.

unwrap("'hello'", "'");        // hello
// No mataching end 'a', so nothing happens
unwrap("apple", "a"); // apple
unwrap("wow", "w"); // o
unwrap(`"'blah'"`, '"', "'"); // blah
  • Parameters

    • source: string
    • Rest...wrappers: readonly string[]

    Returns string