Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (20 sloc) 518 Bytes
import { Pipe, PipeTransform } from '@angular/core';
import { isString } from '../utils/utils';
@Pipe({
name: 'repeat'
})
export class RepeatPipe implements PipeTransform {
transform (input: any, times: number = 1, characters: string = ''): any {
if (!isString(input)) {
return input;
}
if (times <= 0) {
times = 1;
}
const repeated = [input];
for (let i = 1; i < times; ++i) {
repeated.push(input)
}
return repeated.join(characters);
}
}
You can’t perform that action at this time.