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

x/ayonli_jsext/string/index.ts>truncate

A JavaScript extension package for building strong and modern applications.
Latest
function truncate
import { truncate } from "https://deno.land/x/ayonli_jsext@v0.9.72/string/index.ts";

Truncates the string to the given length (including the ending ...).

Examples

Example 1

import { truncate } from "@ayonli/jsext/string";

console.log(truncate("hello world", 8)); // hello...
console.log(truncate("hello world", 11)); // hello world

Parameters

str: string
length: number

Returns

string