initial commit

This commit is contained in:
Chris Chen
2022-09-30 10:53:48 -07:00
commit 911b45739d
1026 changed files with 149872 additions and 0 deletions
View File
+11
View File
@@ -0,0 +1,11 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'ngxCapitalize' })
export class CapitalizePipe implements PipeTransform {
transform(input: string): string {
return input && input.length
? (input.charAt(0).toUpperCase() + input.slice(1).toLowerCase())
: input;
}
}
+5
View File
@@ -0,0 +1,5 @@
export * from './capitalize.pipe';
export * from './plural.pipe';
export * from './round.pipe';
export * from './timing.pipe';
export * from './number-with-commas.pipe';
@@ -0,0 +1,9 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'ngxNumberWithCommas' })
export class NumberWithCommasPipe implements PipeTransform {
transform(input: number): string {
return new Intl.NumberFormat().format(input);
}
}
+14
View File
@@ -0,0 +1,14 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'ngxPlural' })
export class PluralPipe implements PipeTransform {
transform(input: number, label: string, pluralLabel: string = ''): string {
input = input || 0;
return input === 1
? `${input} ${label}`
: pluralLabel
? `${input} ${pluralLabel}`
: `${input} ${label}s`;
}
}
+9
View File
@@ -0,0 +1,9 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'ngxRound' })
export class RoundPipe implements PipeTransform {
transform(input: number): number {
return Math.round(input);
}
}
+18
View File
@@ -0,0 +1,18 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'timing' })
export class TimingPipe implements PipeTransform {
transform(time: number): string {
if (time) {
const minutes = Math.floor(time / 60);
const seconds = Math.floor(time % 60);
return `${this.initZero(minutes)}${minutes}:${this.initZero(seconds)}${seconds}`;
}
return '00:00';
}
private initZero(time: number): string {
return time < 10 ? '0' : '';
}
}