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



commit 6269188ae2afb452db791a5004c5599a9a553c81
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 eb749b1..9ec8491 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);
@@ -220,4 +224,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]