Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ddc_vim/deps.ts>fn.trim

Dark deno-powered completion framework for neovim/Vim
Go to Latest
function fn.trim
import { fn } from "https://deno.land/x/ddc_vim@v4.0.2/deps.ts";
const { trim } = fn;

Return {text} as a String where any character in {mask} is removed from the beginning and/or end of {text}.

If {mask} is not given, {mask} is all characters up to 0x20, which includes Tab, space, NL and CR, plus the non-breaking space character 0xa0.

The optional {dir} argument specifies where to remove the characters: 0 remove from the beginning and end of {text} 1 remove only at the beginning of {text} 2 remove only at the end of {text} When omitted both ends are trimmed.

This function deals with multibyte characters properly. Returns an empty string on error.

Examples:

echo trim("   some text ")

returns "some text"

echo trim("  \r\t\t\r RESERVE \t\n\x0B\xA0") .. "_TAIL"

returns "RESERVE_TAIL"

echo trim("rm<Xrm<>X>rrm", "rm<>")

returns "Xrm<>X" (characters in the middle are not removed)

echo trim("  vim  ", " ", 2)

returns " vim"

Can also be used as a method:

GetText()->trim()

Parameters

denops: Denops
text: unknown
optional
mask: unknown
optional
dir: unknown

Returns

Promise<string>