diff --git a/docs/nconf.html b/docs/nconf.html index b1ffd96..3f4b12c 100644 --- a/docs/nconf.html +++ b/docs/nconf.html @@ -48,7 +48,13 @@ specified type.

@callback {function} Continuation to respond to when complete.

-

Responds with an Object representing all keys associated in this instance.

nconf.load = function (callback) {
+

Responds with an Object representing all keys associated in this instance.

nconf.load = function (callback) {

If we don't have a callback and the current +store is capable of loading synchronously +then do so.

  if (!callback && nconf.store.loadSync) {
+    return nconf.store.loadSync();
+  }
+  
+  
   if (!nconf.store.load) {
     var error = new Error('nconf store ' + nconf.store.type + ' has no load() method');
     if (callback) {
@@ -59,7 +65,7 @@ specified type.

} return nconf.store.load(callback); -};

function save (value, callback)

+};

function save (value, callback)

@value {Object} Optional Config object to set for this instance

@@ -70,6 +76,11 @@ instance and then adds all key-value pairs in value.

if (!callback) { callback = value; value = null; +

If we still don't have a callback and the +current store is capable of saving synchronously +then do so.

    if (!callback && nconf.store.saveSync) {
+      return nconf.store.saveSync();
+    }
   }
   
   if (!nconf.store.save) {
@@ -82,22 +93,22 @@ instance and then adds all key-value pairs in value. 

} return nconf.store.save(value, callback); -};

function reset (callback)

+};

function reset (callback)

@callback {function} Optional Continuation to respond to when complete.

Clears all keys associated with this instance.

nconf.reset = function (callback) {
   return nconf.store.reset(callback);
-};

function key (arguments)

+};

function key (arguments)

Returns a : joined string from the arguments.

nconf.key = function () {
   return Array.prototype.slice.call(arguments).join(':');
-};

function path (key)

+};

function path (key)

@key {string} The ':' delimited key to split

Returns a fully-qualified path to a nested nconf key.

nconf.path = function (key) {
   return key.split(':');
-};

Use the memory engine by default

nconf.use('memory');
+};

Use the memory engine by default

nconf.use('memory');
 
 
\ No newline at end of file diff --git a/docs/nconf/stores/file.html b/docs/nconf/stores/file.html index b8e1393..624dd14 100644 --- a/docs/nconf/stores/file.html +++ b/docs/nconf/stores/file.html @@ -44,7 +44,35 @@ using the format specified by this.format.

fs.writeFile(this.file, this.format.stringify(this.store), function (err) { return err ? callback(err) : callback(); }); -};

function load (callback)

+};

function saveSync (value, callback)

+ +

@value {Object} Ignored Left here for consistency

+ +

@callback {function} Optional Continuation to respond to when complete.

+ +

Saves the current configuration object to disk at this.file +using the format specified by this.format synchronously.

File.prototype.saveSync = function (value, callback) {
+  if (!callback) {
+    callback = value;
+    value = null;
+  }
+  
+  var err;
+  try {
+    fs.writeFileSync(this.file, this.format.stringify(this.store));
+  }
+  catch (ex) {
+    err = ex;
+  }
+  
+  if (callback) {
+    return callback(err);
+  }
+  
+  if (err) {
+    throw err;
+  }
+};

function load (callback)

@callback {function} Continuation to respond to when complete.

@@ -59,6 +87,30 @@ using the format specified by this.format.

self.store = data; callback(null, self.store); }); +};

function load (callback)

+ +

@callback {function} Optional Continuation to respond to when complete.

+ +

Attempts to load the data stored in this.file synchronously and responds appropriately.

File.prototype.loadSync = function (callback) {
+  var err, data;
+  
+  try {
+    data = fs.readFileSync(this.file, 'utf8');
+    this.store = this.format.parse(data);
+  }
+  catch (ex) {
+    err = ex;
+  }
+  
+  if (callback) {
+    return callback(err, data);
+  }
+  
+  if (err) {
+    throw err;
+  }
+  
+  return data;
 };
 
 
\ No newline at end of file