Skip to content

Instantly share code, notes, and snippets.

View shifatul-i's full-sized avatar
:octocat:
Gitting

Shifatul Islam (Sif) shifatul-i

:octocat:
Gitting
View GitHub Profile
@shifatul-i
shifatul-i / short-number.pipe.ts
Last active May 14, 2024 17:00
Angular - short number suffix pipe 1K / 2M / 3B
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'shortNumber'
})
export class ShortNumberPipe implements PipeTransform {
transform(number: number, args?: any): any {
if (isNaN(number)) return null; // will only work value is a number
if (number === null) return null;
@shifatul-i
shifatul-i / date-ago.pipe.ts
Last active December 8, 2022 12:31
Angular — date ago pipe (minutes / hours / days / months / years ago)
import {Pipe, PipeTransform} from '@angular/core';
@Pipe({
name: 'dateAgo',
pure: true
})
export class DateAgoPipe implements PipeTransform {
transform(value: any, args?: any): any {
if (value) {