Comparing version 1.2.8 to 1.2.9
{ | ||
"name": "types.js", | ||
"version": "1.2.8", | ||
"version": "1.2.9", | ||
"description": "A tiny (1.7kb), but essential Javascript type-check library", | ||
@@ -19,3 +19,2 @@ "main": "types.min.js", | ||
"check", | ||
"validation", | ||
"force" | ||
@@ -22,0 +21,0 @@ ], |
@@ -62,16 +62,18 @@ types.js | ||
Client= function( name ){ | ||
// if name is not set or not String, this.name will be set to: 'no name given yet' | ||
this.name= _.forceString( name, 'no name given yet' ); | ||
} | ||
var unborn= new Client(); | ||
console.log( unborn.name ); // 'no name given yet' | ||
var func= null; | ||
// call a function that might not exist anymore: | ||
_.forceFunction( func )( funcArgs ); | ||
_.forceFunction( func )( 'some arguments', 'for func' ); | ||
// no crash, default empty function is called, returns undefined | ||
// or add a replacement function in case the first one fails: | ||
_.forceFunction( func, function(){ | ||
return 'replacement function used'; | ||
})( funcArgs ); | ||
var message= _.forceFunction( func, function(args){ | ||
return 'replacement function used '+ args; | ||
})( 'with some arguments' ); | ||
console.log( message ); | ||
// replacement function used with some arguments | ||
@@ -78,0 +80,0 @@ // some default type checking: |
140959
202