diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-04 10:44:18 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-05 10:53:08 +0200 |
commit | 693263e936763a851e3c8c020e3739def8bd4eca (patch) | |
tree | 7fd333fcf76edbc24f3daf4a78e47ff55f048b04 /client/src/app/shared/misc/number-formatter.pipe.ts | |
parent | 9ba1d64b1ac77304d9ffb1b3432a90ea00ff3281 (diff) | |
download | PeerTube-693263e936763a851e3c8c020e3739def8bd4eca.tar.gz PeerTube-693263e936763a851e3c8c020e3739def8bd4eca.tar.zst PeerTube-693263e936763a851e3c8c020e3739def8bd4eca.zip |
Refactor videos selection components
Diffstat (limited to 'client/src/app/shared/misc/number-formatter.pipe.ts')
-rw-r--r-- | client/src/app/shared/misc/number-formatter.pipe.ts | 19 |
1 files changed, 0 insertions, 19 deletions
diff --git a/client/src/app/shared/misc/number-formatter.pipe.ts b/client/src/app/shared/misc/number-formatter.pipe.ts deleted file mode 100644 index 8a0756a36..000000000 --- a/client/src/app/shared/misc/number-formatter.pipe.ts +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | import { Pipe, PipeTransform } from '@angular/core' | ||
2 | |||
3 | // Thanks: https://github.com/danrevah/ngx-pipes/blob/master/src/pipes/math/bytes.ts | ||
4 | |||
5 | @Pipe({ name: 'myNumberFormatter' }) | ||
6 | export class NumberFormatterPipe implements PipeTransform { | ||
7 | private dictionary: Array<{max: number, type: string}> = [ | ||
8 | { max: 1000, type: '' }, | ||
9 | { max: 1000000, type: 'K' }, | ||
10 | { max: 1000000000, type: 'M' } | ||
11 | ] | ||
12 | |||
13 | transform (value: number) { | ||
14 | const format = this.dictionary.find(d => value < d.max) || this.dictionary[this.dictionary.length - 1] | ||
15 | const calc = Math.floor(value / (format.max / 1000)) | ||
16 | |||
17 | return `${calc}${format.type}` | ||
18 | } | ||
19 | } | ||