model/serverState.js
function(key, value, callback) {
        if (this.get(key) == value) {
            return;
        }

        this.set(key, value);
        clearTimeout(this._saveTimeout);
        this._saveTimeout = setTimeout(_.bind(function() {
            fs.writeFile(this._stateFile, JSON.stringify(this.attributes, null, '\t'), _.bind(function() {
                logger.info(key + ' saved to ' + path.join(process.cwd(), this._stateFile));
                while (this._callbacks && this._callbacks.length) {
                    this._callbacks.shift()();
                }
            }, this));
        }, this), 1000);

        if (callback) {
            if (!this._callbacks) {
                this._callbacks = [];
            }

            this._callbacks.push(callback);
        }
    }
function(key, value, callback) {
        if (this.get(key) == value) {
            return;
        }

        this.set(key, value);
        clearTimeout(this._saveTimeout);
        this._saveTimeout = setTimeout(_.bind(function() {
            fs.writeFile(this._stateFile, JSON.stringify(this.attributes, null, '\t'), _.bind(function() {
                logger.info(key + ' saved to ' + path.join(process.cwd(), this._stateFile));
                while (this._callbacks && this._callbacks.length) {
                    this._callbacks.shift()();
                }
            }, this));
        }, this), 1000);

        if (callback) {
            if (!this._callbacks) {
                this._callbacks = [];
            }

            this._callbacks.push(callback);
        }
    }
function ( key , value , callback ) { if ( this . get ( key ) == value ) { return ; } this . set ( key , value ) ; clearTimeout ( this . _saveTimeout ) ; this . _saveTimeout = setTimeout ( _ . bind ( function ( ) { fs . writeFile ( this . _stateFile , JSON . stringify ( this . attributes , null , '\t' ) , _ . bind ( function ( ) { logger . info ( key + ' saved to ' + path . join ( process . cwd ( ) , this . _stateFile ) ) ; while ( this . _callbacks && this . _callbacks . length ) { this . _callbacks . shift ( ) ( ) ; } } , this ) ) ; } , this ) , 1000 ) ; if ( callback ) { if ( ! this . _callbacks ) { this . _callbacks = [ ] ; } this . _callbacks . push ( callback ) ; } }
Write to the state file.
Write to the state file .