1
1
import { IStackFrame } from 'models/IStackFrame' ;
2
2
3
3
export 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
+
4
22
public static getHashCode ( source :string ) : string {
5
23
if ( ! source || source . length === 0 ) {
6
24
return null ;
@@ -17,11 +35,11 @@ export class Utils {
17
35
}
18
36
19
37
public static getCookies ( cookies :string ) : Object {
20
- var result = { } ;
38
+ var result : Object = { } ;
21
39
22
- var parts = ( cookies || '' ) . split ( '; ' ) ;
40
+ var parts : string [ ] = ( cookies || '' ) . split ( '; ' ) ;
23
41
for ( var index = 0 ; index < parts . length ; index ++ ) {
24
- var cookie = parts [ index ] . split ( '=' ) ;
42
+ var cookie : string [ ] = parts [ index ] . split ( '=' ) ;
25
43
result [ cookie [ 0 ] ] = cookie [ 1 ] ;
26
44
}
27
45
@@ -36,8 +54,8 @@ export class Utils {
36
54
return s4 ( ) + s4 ( ) + '-' + s4 ( ) + '-' + s4 ( ) + '-' + s4 ( ) + '-' + s4 ( ) + s4 ( ) + s4 ( ) ;
37
55
}
38
56
39
- public static merge ( defaultValues :any , values :any ) {
40
- var result = { } ;
57
+ public static merge ( defaultValues :Object , values :Object ) {
58
+ var result : Object = { } ;
41
59
42
60
for ( var key in defaultValues || { } ) {
43
61
if ( ! ! defaultValues [ key ] ) {
@@ -78,7 +96,7 @@ export class Utils {
78
96
return null ;
79
97
}
80
98
81
- var result = { } ;
99
+ var result : Object = { } ;
82
100
for ( var index = 0 ; index < pairs . length ; index ++ ) {
83
101
var pair = pairs [ index ] . split ( '=' ) ;
84
102
result [ decodeURIComponent ( pair [ 0 ] ) ] = decodeURIComponent ( pair [ 1 ] ) ;
@@ -93,7 +111,7 @@ export class Utils {
93
111
94
112
public static stringify ( data :any ) : string {
95
113
function stringifyImpl ( data :any ) : string {
96
- var cache = [ ] ;
114
+ var cache : string [ ] = [ ] ;
97
115
return JSON . stringify ( data , function ( key :string , value :any ) {
98
116
if ( typeof value === 'object' && ! ! value ) {
99
117
if ( cache . indexOf ( value ) !== - 1 ) {
0 commit comments