Fixed warnings
This commit is contained in:
parent
139dd82de0
commit
52b8c90bbf
@ -1,9 +1,10 @@
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'iqser-hidden-action',
|
||||
templateUrl: './hidden-action.component.html',
|
||||
styleUrls: ['./hidden-action.component.scss']
|
||||
styleUrls: ['./hidden-action.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class HiddenActionComponent {
|
||||
@Input() requiredClicks = 4;
|
||||
|
||||
@ -18,10 +18,10 @@ export function humanize(value: string, lowercase = true): string {
|
||||
|
||||
export const log = tap(console.log);
|
||||
|
||||
export const toNumber = (str: string) => {
|
||||
export function toNumber(str: string): number {
|
||||
try {
|
||||
return parseInt(`${str}`.replace(/\D/g, ''), 10);
|
||||
} catch (e) {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -3,26 +3,27 @@ import { TranslateLoader } from '@ngx-translate/core';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
interface T {
|
||||
[key: string]: string | T;
|
||||
}
|
||||
|
||||
export class PruningTranslationLoader implements TranslateLoader {
|
||||
constructor(private _http: HttpClient, private _prefix: string, private _suffix: string) {}
|
||||
|
||||
getTranslation(lang: string): Observable<Record<string, unknown>> {
|
||||
return this._http
|
||||
.get(`${this._prefix}${lang}${this._suffix}`)
|
||||
.pipe(map((result: Record<string, unknown>) => this._process(result)));
|
||||
getTranslation(lang: string): Observable<T> {
|
||||
return this._http.get(`${this._prefix}${lang}${this._suffix}`).pipe(map(result => this._process(result as T)));
|
||||
}
|
||||
|
||||
private _process(object: unknown): Record<string, unknown> {
|
||||
private _process(object: T): T {
|
||||
return (
|
||||
Object.keys(object)
|
||||
// eslint-disable-next-line no-prototype-builtins
|
||||
.filter(key => object.hasOwnProperty(key) && object[key] !== '')
|
||||
.reduce(
|
||||
(result: Record<string, unknown>, key) => (
|
||||
(result[key] = typeof object[key] === 'object' ? this._process(object[key]) : object[key]),
|
||||
result
|
||||
(result: T, key) => (
|
||||
(result[key] = typeof object[key] === 'object' ? this._process(object[key] as T) : object[key]), result
|
||||
),
|
||||
{},
|
||||
{}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user