• Strips list if matches prefix, otherwise returns none.

    Type Parameters

    • T

    Parameters

    • equalityT: PartialEq<T, T>

      The equality for T.

    Returns ((prefix) => ((list) => Option<List<T>>))

    The stripped list.

    Examples

    import { fromString, stripPrefix, toString } from "./list.ts";
    import * as Option from "./option.ts";
    import { assertEquals } from "../deps.ts";
    import { strict } from "./type-class/partial-eq.ts";

    const stripFoo = stripPrefix(strict<string>())(fromString("foo"));

    {
    const optList = stripFoo(fromString("foobar"));
    const optStr = Option.map(toString)(optList);
    assertEquals(optStr, Option.some("bar"));
    }
    {
    const optList = stripFoo(fromString("foo"));
    const optStr = Option.map(toString)(optList);
    assertEquals(optStr, Option.some(""));
    }
    {
    const optList = stripFoo(fromString("barfoo"));
    const optStr = Option.map(toString)(optList);
    assertEquals(optStr, Option.none());
    }

Generated using TypeDoc