Comparing version 2.1.1 to 2.2.0
12
IsA.js
@@ -82,2 +82,14 @@ 'use strict' | ||
}, | ||
isValidPath: function (object, path) { | ||
if ( !path ) return true | ||
let oPath = path.split('.') | ||
if ( !object && oPath.length === 0 ) return true | ||
for ( let key of oPath ) { | ||
if ( !object || !object[key] ) return false | ||
object = object[ key ] | ||
} | ||
return true | ||
}, | ||
parameterNames: function ( func ) { | ||
@@ -84,0 +96,0 @@ var fnStr = func.toString().replace(STRIP_COMMENTS, '') |
{ | ||
"name": "isa.js", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"description": "Very minimal collection is isA functions. isObject, isArray, isDate...", | ||
@@ -26,5 +26,5 @@ "homepage": "https://github.com/imrefazekas/isa", | ||
"gulp": "^3.9.1", | ||
"gulp-eslint": "^4.0.0", | ||
"gulp-eslint": "^4.0.1", | ||
"gulp-load-plugins": "^1.5.0", | ||
"gulp-mocha": "^4.3.1", | ||
"gulp-mocha": "^5.0.0", | ||
"gulp-rename": "^1.2.2", | ||
@@ -31,0 +31,0 @@ "gulp-uglify": "^3.0.0" |
@@ -39,2 +39,14 @@ 'use strict' | ||
}) | ||
it('Path check', function (done) { | ||
let p = { data: 'hello', content: { name: 'Peter' } } | ||
expect( _.isValidPath( p, 'data' ) ).to.be.true | ||
expect( _.isValidPath( p, 'name' ) ).to.be.false | ||
expect( _.isValidPath( p, '' ) ).to.be.true | ||
expect( _.isValidPath( p, null ) ).to.be.true | ||
expect( _.isValidPath( null, '' ) ).to.be.true | ||
expect( _.isValidPath( null, 'name' ) ).to.be.false | ||
expect( _.isValidPath( p, 'content' ) ).to.be.true | ||
expect( _.isValidPath( p, 'content.name' ) ).to.be.true | ||
done() | ||
}) | ||
}) | ||
@@ -41,0 +53,0 @@ |
12650
302