Skip to content

truncate

긴 문자열을 지정된 길이로 잘라내고, 문자열 뒤에 선택적으로 줄임표를 추가합니다.

Parameters

이름타입필수기본값
strstring
lengthnumber
ellipsisnamedstring''

named 표시가 있는 파라미터는 Dart에서는 named 파라미터, Python에서는 키워드 인자로 전달됩니다.

Returns

string

Examples

javascript
truncate('hello', 3); // Returns 'hel'
truncate('hello', 2, '...'); // Returns 'he...'
dart
truncate('hello', 3); // Returns 'hel'
truncate('hello', 2, ellipsis: '...'); // Returns 'he...'
python
truncate('hello', 3)  # Returns 'hel'
truncate('hello', 2, '...')  # Returns 'he...'

Released under the MIT License