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

x/typeorm/src/util/StringUtils.ts>shorten

Forked from https://github.com/typeorm/typeorm
Latest
function shorten
import { shorten } from "https://deno.land/x/typeorm@v0.2.23-rc10/src/util/StringUtils.ts";

Shorten a given input. Useful for RDBMS imposing a limit on the maximum length of aliases and column names in SQL queries.

Examples

// returns: "UsShCa__orde__mark__dire" shorten('UserShoppingCart__order__market__director')

// returns: "cat_wit_ver_lon_nam_pos_wit_ver_lon_nam_pos_wit_ver_lon_nam" shorten( 'category_with_very_long_name_posts_with_very_long_name_post_with_very_long_name', { separator: '_', segmentLength: 3 } )

// equals: UsShCa__orde__mark_market_id ${shorten('UserShoppingCart__order__market')}_market_id

Parameters

input: string

String to be shortened.

optional
options: IShortenOptions = [UNSUPPORTED]

Default to 4 for segments length, 2 for terms length, '__' as a separator.

Returns

string

Shortened input.