Created
May 25, 2012 19:14
-
-
Save neagle/2789974 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([], function () { | |
var Wiser = window.Wiser || {}; | |
if (typeof Wiser === 'object') { | |
Wiser.utils = Wiser.utils || {}; | |
if (typeof Wiser.utils === 'object') { | |
/* WiserTogether Utility Functions | |
* | |
*/ | |
/* getProperty: checks a long object property chain for a value and | |
* returns undefined if any property along the chain does not exist | |
* instead of throwing an error | |
*/ | |
Wiser.utils.getProperty = function (object, propertiesString) { | |
var i, | |
length, | |
split = propertiesString.split('.'); | |
for (i = 0, length = split.length; i < length; i += 1) { | |
object = object[split[i]]; | |
if (object === undefined) { | |
// Can't proceed | |
break; | |
} | |
} | |
return object; | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment