feat: assessments module

This commit is contained in:
Thea Schöbl
2022-03-17 09:59:52 +00:00
parent eea8d6d339
commit e68d1b73f9
51 changed files with 3372 additions and 222 deletions

View File

@@ -356,6 +356,34 @@ export class MetersLocalizedPipe implements PipeTransform, OnDestroy {
}
}
@Injectable()
@Pipe({
name: 'isNaN',
pure: true,
})
export class IsNaNPipe implements PipeTransform {
transform(value: unknown): boolean {
return Number.isNaN(value);
}
}
@Injectable()
@Pipe({
name: 'isNumeric',
pure: true,
})
export class IsNumericPipe implements PipeTransform {
transform(value: unknown): boolean {
return !Number.isNaN(
typeof value === 'number'
? value
: typeof value === 'string'
? Number.parseFloat(value)
: Number.NaN,
);
}
}
@Injectable()
@Pipe({
name: 'numberLocalized',

View File

@@ -25,6 +25,8 @@ import {
DurationLocalizedPipe,
ToUnixPipe,
EntriesPipe,
IsNaNPipe,
IsNumericPipe,
} from './common-string-pipes';
import {
ThingTranslateDefaultParser,
@@ -56,6 +58,8 @@ export interface ThingTranslateModuleConfig {
SentenceCasePipe,
ToUnixPipe,
EntriesPipe,
IsNaNPipe,
IsNumericPipe,
],
exports: [
ArrayJoinPipe,
@@ -71,6 +75,8 @@ export interface ThingTranslateModuleConfig {
SentenceCasePipe,
ToUnixPipe,
EntriesPipe,
IsNaNPipe,
IsNumericPipe,
],
})
export class ThingTranslateModule {