Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
17 lines (14 sloc) 425 Bytes
import { Pipe, PipeTransform } from '@angular/core';
import { isString } from '../helpers/helpers';
@Pipe({ name: 'lpad' })
export class LeftPadPipe implements PipeTransform {
transform(str: string, length: number, padCharacter: string = ' '): string {
if (!isString(str) || str.length >= length) {
return str;
}
while (str.length < length) {
str = padCharacter + str;
}
return str;
}
}
You can’t perform that action at this time.