Skip to content

Instantly share code, notes, and snippets.

View msteini82's full-sized avatar

msteini82

  • Berlin, Germany
View GitHub Profile
@msteini82
msteini82 / file-size.pipe.ts
Last active February 25, 2020 11:10 — forked from JonCatmull/file-size.pipe.ts
Angular2 + TypeScript file size Pipe/Filter. Convert bytes into largest possible unit. e.g. 1024 => 1 KB - Using standard decimal pipe to convert number to local format.
import { Pipe, PipeTransform, LOCALE_ID, Inject } from '@angular/core';
import {DecimalPipe} from '@angular/common';
/*
* Convert bytes into largest possible unit.
* Takes an precision argument that defaults to 2.
* Usage:
* bytes | fileSize:precision
* Example:
* {{ 1024 | fileSize}}