Improve top played part

Sort by avg. play + Slice
Add round pipe
Comment ELS Service
This commit is contained in:
2018-03-21 00:49:50 +01:00
parent 6300e9cfc7
commit 330adb4b9f
6 changed files with 60 additions and 7 deletions

View File

@@ -0,0 +1,21 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'round'
})
export class RoundPipe implements PipeTransform {
/**
* Round a value
* @param value value to round
* @param precision number of numbers to keep after coma - 1 if unspecified
*/
transform(value: number, precision?: number): number {
if (precision === undefined) {
precision = 1;
}
const factor = Math.pow(10, precision);
return Math.round(value * factor) / factor;
}
}