[gnome-maps/wip/routing: 39/45] Utils: add isDefined function.



commit ea40dfacdb0a127f31b11f3009715b20cdeaa52a
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date:   Sun Aug 25 02:58:29 2013 +0200

    Utils: add isDefined function.
    
    Utils.isDefined returns true if a value isn't undefined or null.

 src/utils.js |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/src/utils.js b/src/utils.js
index 3d0942b..4e441ed 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -138,6 +138,10 @@ function isArray(obj) {
     return Object.prototype.toString.call(obj) === '[object Array]';
 }
 
+function isDefined(obj) {
+    return (typeof obj !== 'undefined' && obj !== null);
+}
+
 function load_icon(icon, size, loadCompleteCallback) {
     if (icon instanceof Gio.FileIcon) {
         _load_file_icon(icon, loadCompleteCallback);
@@ -219,4 +223,4 @@ function _load_themed_icon(icon, size, loadCompleteCallback) {
     } catch(e) {
         log("Failed to load pixbuf: " + e);
     }
-}
+}
\ No newline at end of file


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]