Project

General

Profile

1
export class HelperFunctions {
2
  //Use this class function to create queryParams Objects in format {key1:value1} or {key1:value1,key2:value2,key3:value3,...} for  multiple parameters
3
  constructor() {}
4

    
5
  public static scroll() {
6
    if (typeof document !== 'undefined') {
7
      //this.element.nativeElement.scrollIntoView();
8
      window.scrollTo(0, 0);
9
    }
10
  }
11

    
12
  public static isTiny(url: string) {
13
    return (url.indexOf('tinyurl.com') !== -1);
14
  }
15

    
16
  public static copy(element: any): any {
17
    // return JSON.parse(JSON.stringify(element));
18
    // return { ...element};
19
    return Object.assign(Object.create(element), element);
20
  }
21

    
22
  public static encodeArray(elements: string[]): string[] {
23
    let encoded: string[] = [];
24
    elements.forEach(element => {
25
      encoded.push(encodeURIComponent(element));
26
    });
27
    return encoded;
28
  }
29
}
(1-1/18)