11import { IStackFrame } from 'models/IStackFrame' ;
22
33export class Utils {
4+ public static addRange < T > ( target :T [ ] , ...values :T [ ] ) {
5+ if ( ! target ) {
6+ target = [ ] ;
7+ }
8+
9+ if ( ! values || values . length === 0 ) {
10+ return target ;
11+ }
12+
13+ for ( var index = 0 ; index < values . length ; index ++ ) {
14+ if ( values [ index ] && target . indexOf ( values [ index ] ) < 0 ) {
15+ target . push ( values [ index ] ) ;
16+ }
17+ }
18+
19+ return target ;
20+ }
21+
422 public static getHashCode ( source :string ) : string {
523 if ( ! source || source . length === 0 ) {
624 return null ;
@@ -17,11 +35,11 @@ export class Utils {
1735 }
1836
1937 public static getCookies ( cookies :string ) : Object {
20- var result = { } ;
38+ var result : Object = { } ;
2139
22- var parts = ( cookies || '' ) . split ( '; ' ) ;
40+ var parts : string [ ] = ( cookies || '' ) . split ( '; ' ) ;
2341 for ( var index = 0 ; index < parts . length ; index ++ ) {
24- var cookie = parts [ index ] . split ( '=' ) ;
42+ var cookie : string [ ] = parts [ index ] . split ( '=' ) ;
2543 result [ cookie [ 0 ] ] = cookie [ 1 ] ;
2644 }
2745
@@ -36,8 +54,8 @@ export class Utils {
3654 return s4 ( ) + s4 ( ) + '-' + s4 ( ) + '-' + s4 ( ) + '-' + s4 ( ) + '-' + s4 ( ) + s4 ( ) + s4 ( ) ;
3755 }
3856
39- public static merge ( defaultValues :any , values :any ) {
40- var result = { } ;
57+ public static merge ( defaultValues :Object , values :Object ) {
58+ var result : Object = { } ;
4159
4260 for ( var key in defaultValues || { } ) {
4361 if ( ! ! defaultValues [ key ] ) {
@@ -78,7 +96,7 @@ export class Utils {
7896 return null ;
7997 }
8098
81- var result = { } ;
99+ var result : Object = { } ;
82100 for ( var index = 0 ; index < pairs . length ; index ++ ) {
83101 var pair = pairs [ index ] . split ( '=' ) ;
84102 result [ decodeURIComponent ( pair [ 0 ] ) ] = decodeURIComponent ( pair [ 1 ] ) ;
@@ -93,7 +111,7 @@ export class Utils {
93111
94112 public static stringify ( data :any ) : string {
95113 function stringifyImpl ( data :any ) : string {
96- var cache = [ ] ;
114+ var cache : string [ ] = [ ] ;
97115 return JSON . stringify ( data , function ( key :string , value :any ) {
98116 if ( typeof value === 'object' && ! ! value ) {
99117 if ( cache . indexOf ( value ) !== - 1 ) {
0 commit comments