src/preferences/PreferencesBase.js
function (id, scope, options) {
            var promise;
            options = options || {};

            if (this._scopes[id]) {
                throw new Error("Attempt to redefine preferences scope: " + id);
            }

            // Check to see if scope is a Storage that needs to be wrapped
            if (!scope.get) {
                scope = new Scope(scope);
            }

            promise = scope.load();

            this._addToScopeOrder(id, scope, promise, options.before);

            promise
                .fail(function (err) {
                    // With preferences, it is valid for there to be no file.
                    // It is not valid to have an unparseable file.
                    if (err instanceof ParsingError) {
                        console.error(err);
                    }
                });

            return promise;
        }
function (id, scope, options) {
            var promise;
            options = options || {};

            if (this._scopes[id]) {
                throw new Error("Attempt to redefine preferences scope: " + id);
            }

            // Check to see if scope is a Storage that needs to be wrapped
            if (!scope.get) {
                scope = new Scope(scope);
            }

            promise = scope.load();

            this._addToScopeOrder(id, scope, promise, options.before);

            promise
                .fail(function (err) {
                    // With preferences, it is valid for there to be no file.
                    // It is not valid to have an unparseable file.
                    if (err instanceof ParsingError) {
                        console.error(err);
                    }
                });

            return promise;
        }
function ( id , scope , options ) { var promise ; options = options || { } ; if ( this . _scopes [ id ] ) { throw new Error ( "Attempt to redefine preferences scope: " + id ) ; } // Check to see if scope is a Storage that needs to be wrapped if ( ! scope . get ) { scope = new Scope ( scope ) ; } promise = scope . load ( ) ; this . _addToScopeOrder ( id , scope , promise , options . before ) ; promise . fail ( function ( err ) { // With preferences, it is valid for there to be no file. // It is not valid to have an unparseable file. if ( err instanceof ParsingError ) { console . error ( err ) ; } } ) ; return promise ; }
Adds a new Scope. New Scopes are added at the highest precedence, unless the "before" option
is given. The new Scope is automatically loaded.

@param {string} id Name of the Scope
@param {Scope|Storage} scope the Scope object itself. Optionally, can be given a Storage directly for convenience.
@param {{before: string}} options optional behavior when adding (e.g. setting which scope this comes before)
@return {Promise} Promise that is resolved when the Scope is loaded. It is resolved
with id and scope.
Adds a new Scope . New Scopes are added at the highest precedence unless the before option is given . The new Scope is automatically loaded .