[gnome-maps/wip/routing: 48/52] Utils: add isDefined function.



commit 7be469e6a15627e0d17c06464bef8269a3d650ef
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 744b781..4595744 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -137,6 +137,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);
@@ -179,4 +183,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]