Skip to content
This repository has been archived by the owner on Mar 29, 2024. It is now read-only.

Commit

Permalink
Add round pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
ppacher committed Oct 10, 2023
1 parent 4a139cd commit bb7329e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions modules/portmaster/src/app/shared/pipes/round.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'round',
pure: true,
})
export class RoundPipe implements PipeTransform {
transform(value: number, roundBy: number) {
if (isNaN(value)) {
return NaN
}

return Math.floor(value / roundBy) * roundBy
}
}

0 comments on commit bb7329e

Please sign in to comment.