Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion text/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"./unstable-to-sentence-case": "./unstable_to_sentence_case.ts",
"./to-snake-case": "./to_snake_case.ts",
"./unstable-to-title-case": "./unstable_to_title_case.ts",
"./unstable-truncate": "./unstable_truncate.ts",
"./truncate": "./truncate.ts",
"./word-similarity-sort": "./word_similarity_sort.ts"
}
}
1 change: 1 addition & 0 deletions text/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ export * from "./to_camel_case.ts";
export * from "./to_kebab_case.ts";
export * from "./to_pascal_case.ts";
export * from "./to_snake_case.ts";
export * from "./truncate.ts";
10 changes: 4 additions & 6 deletions text/unstable_truncate.ts → text/truncate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ export interface TruncateOptions {
* Note: this function is not grapheme-cluster-aware. Combining characters, flag
* emoji, and ZWJ sequences may still be visually split.
*
* @experimental **UNSTABLE**: New API, yet to be vetted.
*
* @param str The string to truncate.
* @param maxLength The maximum length of the returned string (must be a
* non-negative integer).
Expand All @@ -43,7 +41,7 @@ export interface TruncateOptions {
*
* @example End truncation (default)
* ```ts
* import { truncate } from "@std/text/unstable-truncate";
* import { truncate } from "@std/text/truncate";
* import { assertEquals } from "@std/assert";
*
* assertEquals(truncate("Hello, world!", 8), "Hello, …");
Expand All @@ -52,7 +50,7 @@ export interface TruncateOptions {
*
* @example Middle truncation
* ```ts
* import { truncate } from "@std/text/unstable-truncate";
* import { truncate } from "@std/text/truncate";
* import { assertEquals } from "@std/assert";
*
* assertEquals(
Expand All @@ -63,7 +61,7 @@ export interface TruncateOptions {
*
* @example Start truncation
* ```ts
* import { truncate } from "@std/text/unstable-truncate";
* import { truncate } from "@std/text/truncate";
* import { assertEquals } from "@std/assert";
*
* assertEquals(
Expand All @@ -74,7 +72,7 @@ export interface TruncateOptions {
*
* @example Custom suffix
* ```ts
* import { truncate } from "@std/text/unstable-truncate";
* import { truncate } from "@std/text/truncate";
* import { assertEquals } from "@std/assert";
*
* assertEquals(
Expand Down
2 changes: 1 addition & 1 deletion text/unstable_truncate_test.ts → text/truncate_test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2018-2026 the Deno authors. MIT license.
import { assertEquals } from "@std/assert/equals";
import { assertThrows } from "@std/assert/throws";
import { truncate } from "./unstable_truncate.ts";
import { truncate } from "./truncate.ts";

Deno.test("truncate() returns empty string when maxLength is zero", () => {
assertEquals(truncate("hello", 0), "");
Expand Down
Loading