Improve top played part
Sort by avg. play + Slice Add round pipe Comment ELS Service
This commit is contained in:
21
dashboard/src/app/pipes/round.pipe.ts
Normal file
21
dashboard/src/app/pipes/round.pipe.ts
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user