File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -146,6 +146,8 @@ export class StringMapWrapper {
146
146
147
147
static keys ( map : { [ key : string ] : any } ) : string [ ] { return Object . keys ( map ) ; }
148
148
149
+ static size ( map : { [ key : string ] : any } ) : number { return StringMapWrapper . keys ( map ) . length ; }
150
+
149
151
static isEmpty ( map : { [ key : string ] : any } ) : boolean {
150
152
for ( var prop in map ) {
151
153
return false ;
Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ export function isDate( obj ): boolean {
80
80
return obj instanceof Date && ! isNaN ( obj . valueOf ( ) ) ;
81
81
}
82
82
83
- export function isType ( obj : any ) : boolean {
83
+ export function isType ( obj : any ) : obj is Type {
84
84
return isFunction ( obj ) ;
85
85
}
86
86
@@ -229,6 +229,42 @@ function _firstTo( value: string, cb: Function ): string {
229
229
return cb . call ( value . charAt ( 0 ) ) + value . substring ( 1 ) ;
230
230
}
231
231
232
+ export function normalizeBlank ( obj : Object ) : any {
233
+ return isBlank ( obj ) ? null : obj ;
234
+ }
235
+
236
+ export function normalizeBool ( obj : boolean ) : boolean {
237
+ return isBlank ( obj ) ? false : obj ;
238
+ }
239
+
240
+ export function print ( obj : Error | Object ) {
241
+ console . log ( obj ) ;
242
+ }
243
+
244
+ /**
245
+ * Angular 2 setValueOnPath
246
+ * supports only `.` path separator
247
+ * @param global
248
+ * @param path
249
+ * @param value
250
+ */
251
+ export function setValueOnPath ( global : any , path : string , value : any ) {
252
+ var parts = path . split ( '.' ) ;
253
+ var obj : any = global ;
254
+ while ( parts . length > 1 ) {
255
+ var name = parts . shift ( ) ;
256
+ if ( obj . hasOwnProperty ( name ) && isPresent ( obj [ name ] ) ) {
257
+ obj = obj [ name ] ;
258
+ } else {
259
+ obj = obj [ name ] = { } ;
260
+ }
261
+ }
262
+ if ( obj === undefined || obj === null ) {
263
+ obj = { } ;
264
+ }
265
+ obj [ parts . shift ( ) ] = value ;
266
+ }
267
+
232
268
/**
233
269
* Converts `value` to an object if it's not one.
234
270
*
You can’t perform that action at this time.
0 commit comments