mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 08:43:33 +00:00
Move to libs
This commit is contained in:
17
libs/angular/src/pipes/ellipsis.pipe.ts
Normal file
17
libs/angular/src/pipes/ellipsis.pipe.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Pipe, PipeTransform } from "@angular/core";
|
||||
|
||||
@Pipe({
|
||||
name: "ellipsis",
|
||||
})
|
||||
export class EllipsisPipe implements PipeTransform {
|
||||
transform(value: string, limit = 25, completeWords = false, ellipsis = "...") {
|
||||
if (value.length <= limit) {
|
||||
return value;
|
||||
}
|
||||
limit -= ellipsis.length;
|
||||
if (completeWords && value.length > limit && value.indexOf(" ") > 0) {
|
||||
limit = value.substring(0, limit).lastIndexOf(" ");
|
||||
}
|
||||
return value.substring(0, limit) + ellipsis;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user