Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "trim"

Index

Variables

Variables

Const trim

trim: (x: A) => B = memoize1<string, Stringer<string>>((chars = " \t\n\r") => {chars = `(${chars.split("").map((x) => `\\${x}`).join("|")})`;const re = new RegExp(`(^${chars}+)|(${chars}+$)`, "g");return (x) => x.replace(re, "");})

Higher order trim function (both sides) with support for user defined trimmable characters (default: whitespace only).

example
trim()("  Hello   ")
// "Hello"

trim(" -+")("-+-+- Hello -+-+-")
// "Hello"
param

-

Type declaration

    • (x: A): B
    • Parameters

      • x: A

      Returns B

Generated using TypeDoc