<A extends string>(self: A): Trim<A>Removes whitespace from both ends of a string.
Example (Trimming whitespace)
import { String } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(String.trim(" a "), "a")
assert.deepStrictEqual(String.trim(" hello world "), "hello world")transforming
Source effect/String.ts:2981 lines
export const const trim: <A extends string>(
self: A
) => Trim<A>
Removes whitespace from both ends of a string.
Example (Trimming whitespace)
import { String } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(String.trim(" a "), "a")
assert.deepStrictEqual(String.trim(" hello world "), "hello world")
trim = <function (type parameter) A in <A extends string>(self: A): Trim<A>A extends string>(self: A extends stringself: function (type parameter) A in <A extends string>(self: A): Trim<A>A): type Trim<A extends string> =
TrimStart<A> extends
| `${infer B} `
| `${infer B}
`
| `${infer B}\t`
| `${infer B}\r`
? TrimEnd<B>
: TrimStart<A>
Type-level representation of trimming whitespace from both ends of a string.
Example (Trimming whitespace at the type level)
import type { String } from "effect"
type Result = String.Trim<" hello "> // "hello"
Trim<function (type parameter) A in <A extends string>(self: A): Trim<A>A> => self: A extends stringself.String.trim(): stringRemoves the leading and trailing white space and line terminator characters from a string.
trim() as type Trim<A extends string> =
TrimStart<A> extends
| `${infer B} `
| `${infer B}
`
| `${infer B}\t`
| `${infer B}\r`
? TrimEnd<B>
: TrimStart<A>
Type-level representation of trimming whitespace from both ends of a string.
Example (Trimming whitespace at the type level)
import type { String } from "effect"
type Result = String.Trim<" hello "> // "hello"
Trim<function (type parameter) A in <A extends string>(self: A): Trim<A>A>Referenced by 1 symbols