From c9e60d96b58419a1af415daf6943faedb474f1f3 Mon Sep 17 00:00:00 2001 From: indexzero Date: Sun, 5 Jun 2011 01:35:54 -0400 Subject: [PATCH] [doc] Update code docs --- lib/nconf/provider.js | 18 ++++++++++++++++++ lib/nconf/stores/memory.js | 8 ++++++++ lib/nconf/stores/redis.js | 15 +++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/lib/nconf/provider.js b/lib/nconf/provider.js index ee0b4db..b9c1125 100644 --- a/lib/nconf/provider.js +++ b/lib/nconf/provider.js @@ -7,6 +7,12 @@ var stores = require('./stores'); +// +// ### function Provider (options) +// #### @options {Object} Options for this instance. +// Constructor function for the Provider object responsible +// for exposing the pluggable storage features of `nconf`. +// var Provider = exports.Provider = function (options) { options = options || {}; this.store = stores.create(options.type || 'memory', options); @@ -46,6 +52,18 @@ Provider.prototype.set = function (key, value, callback) { return this.store.set(key, value, callback); }; +// +// ### function merge (key, value) +// #### @key {string} Key to merge the value into +// #### @value {literal|Object} Value to merge into the key +// Merges the properties in `value` into the existing object value +// at `key`. If the existing value `key` is not an Object, it will be +// completely overwritten. +// +Provider.prototype.merge = function (key, value, callback) { + return this.store.merge(key, value, callback); +} + // // ### function clear (key, callback) // #### @key {string} Key to remove from this instance diff --git a/lib/nconf/stores/memory.js b/lib/nconf/stores/memory.js index d65a0b8..2ef3f67 100644 --- a/lib/nconf/stores/memory.js +++ b/lib/nconf/stores/memory.js @@ -112,6 +112,14 @@ Memory.prototype.clear = function (key) { return true; }; +// +// ### function merge (key, value) +// #### @key {string} Key to merge the value into +// #### @value {literal|Object} Value to merge into the key +// Merges the properties in `value` into the existing object value +// at `key`. If the existing value `key` is not an Object, it will be +// completely overwritten. +// Memory.prototype.merge = function (key, value) { // // If the key is not an `Object` or is an `Array`, diff --git a/lib/nconf/stores/redis.js b/lib/nconf/stores/redis.js index e990a57..3935996 100644 --- a/lib/nconf/stores/redis.js +++ b/lib/nconf/stores/redis.js @@ -162,6 +162,15 @@ Redis.prototype.set = function (key, value, callback) { }); }; +// +// ### function merge (key, value, callback) +// #### @key {string} Key to merge the value into +// #### @value {literal|Object} Value to merge into the key +// #### 2callback {function} Continuation to respond to when complete. +// Merges the properties in `value` into the existing object value +// at `key`. If the existing value `key` is not an Object, it will be +// completely overwritten. +// Redis.prototype.merge = function (key, value, callback) { // // If the key is not an `Object` or is an `Array`, @@ -358,6 +367,12 @@ Redis.prototype.reset = function (callback) { }); }; +// +// ### @private function _addKeys (key, callback) +// #### @key {string} Key to add parent keys for +// #### @callback {function} Continuation to respond to when complete. +// Adds the full `key` path to Redis via `sadd`. +// Redis.prototype._addKeys = function (key, callback) { var self = this, path = nconf.path(key);