dist/melonjs.js
function add(props) {
           Object.keys(props).forEach(function (key) {
             if (isReserved(key)) {
               return;
             }

             (function (prop) {
               Object.defineProperty(api, prop, {
                 configurable: true,
                 enumerable: true,

                 /**
                  * @ignore
                  */
                 get: function get() {
                   return data[prop];
                 },

                 /**
                  * @ignore
                  */
                 set: function set(value) {
                   data[prop] = value;

                   if (me.device.localStorage === true) {
                     localStorage.setItem("me.save." + prop, JSON.stringify(value));
                   }
                 }
               });
             })(key); // Set default value for key


             if (!(key in data)) {
               api[key] = props[key];
             }
           }); // Save keys

           if (me.device.localStorage === true) {
             localStorage.setItem("me.save", JSON.stringify(Object.keys(data)));
           }
         }
function add(props) {
           Object.keys(props).forEach(function (key) {
             if (isReserved(key)) {
               return;
             }

             (function (prop) {
               Object.defineProperty(api, prop, {
                 configurable: true,
                 enumerable: true,

                 /**
                  * @ignore
                  */
                 get: function get() {
                   return data[prop];
                 },

                 /**
                  * @ignore
                  */
                 set: function set(value) {
                   data[prop] = value;

                   if (me.device.localStorage === true) {
                     localStorage.setItem("me.save." + prop, JSON.stringify(value));
                   }
                 }
               });
             })(key); // Set default value for key


             if (!(key in data)) {
               api[key] = props[key];
             }
           }); // Save keys

           if (me.device.localStorage === true) {
             localStorage.setItem("me.save", JSON.stringify(Object.keys(data)));
           }
         }
function add ( props ) { Object . keys ( props ) . forEach ( function ( key ) { if ( isReserved ( key ) ) { return ; } ( function ( prop ) { Object . defineProperty ( api , prop , { configurable : true , enumerable : true , /**
                  * @ignore
                  */ get : function get ( ) { return data [ prop ] ; } , /**
                  * @ignore
                  */ set : function set ( value ) { data [ prop ] = value ; if ( me . device . localStorage === true ) { localStorage . setItem ( "me.save." + prop , JSON . stringify ( value ) ) ; } } } ) ; } ) ( key ) ; // Set default value for key if ( ! ( key in data ) ) { api [ key ] = props [ key ] ; } } ) ; // Save keys if ( me . device . localStorage === true ) { localStorage . setItem ( "me.save" , JSON . stringify ( Object . keys ( data ) ) ) ; } }
Add new keys to localStorage and set them to the given default values if they do not exist
@name add
@memberOf me.save
@function
@param {Object} props key and corresponding values
@example
// Initialize "score" and "lives" with default values
me.save.add({ score : 0, lives : 3 });
Add new keys to localStorage and set them to the given default values if they do not exist