2011-08-28 14:43:34 +00:00
<!DOCTYPE html> < html > < head > < title > stores.js< / title > < meta http-equiv = "content-type" content = "text/html; charset=UTF-8" > < link rel = "stylesheet" media = "all" href = "../docco.css" / > < / head > < body > < div id = "container" > < div id = "background" > < / div > < div id = "jump_to" > Jump To … < div id = "jump_wrapper" > < div id = "jump_page" > < a class = "source" href = "..//nconf/common.html" > nconf/common.html < / a > < a class = "source" href = "..//nconf/formats.html" > nconf/formats.html < / a > < a class = "source" href = "..//nconf/provider.html" > nconf/provider.html < / a > < a class = "source" href = "..//nconf/stores/file.html" > nconf/stores/file.html < / a > < a class = "source" href = "..//nconf/stores/memory.html" > nconf/stores/memory.html < / a > < a class = "source" href = "..//nconf/stores.html" > nconf/stores.html < / a > < a class = "source" href = "..//nconf.html" > nconf.html < / a > < / div > < / div > < / div > < table cellpadding = "0" cellspacing = "0" > < thead > < tr > < th class = "docs" > < h1 > stores.js < / h1 > < / th > < th class = "code" > < / th > < / tr > < / thead > < tbody > < tr id = "section-1" > < td class = "docs" > < div class = "pilwrap" > < a class = "pilcrow" href = "#section-1" > ¶ < / a > < / div > < / td > < td class = "code" > < div class = "highlight" > < pre > < span class = "cm" > /*< / span >
2011-04-02 08:42:26 +00:00
< span class = "cm" > * stores.js: Top-level include for all nconf stores< / span >
< span class = "cm" > *< / span >
< span class = "cm" > * (C) 2011, Charlie Robbins< / span >
< span class = "cm" > *< / span >
< span class = "cm" > */< / span >
2011-06-05 05:39:39 +00:00
< span class = "kd" > var< / span > < span class = "nx" > fs< / span > < span class = "o" > =< / span > < span class = "nx" > require< / span > < span class = "p" > (< / span > < span class = "s1" > ' fs' < / span > < span class = "p" > ),< / span >
< span class = "nx" > stores< / span > < span class = "o" > =< / span > < span class = "nx" > exports< / span > < span class = "p" > ;< / span >
2011-04-02 08:42:26 +00:00
< span class = "kd" > function< / span > < span class = "nx" > capitalize< / span > < span class = "p" > (< / span > < span class = "nx" > str< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< span class = "k" > return< / span > < span class = "nx" > str< / span > < span class = "o" > & & < / span > < span class = "nx" > str< / span > < span class = "p" > [< / span > < span class = "mi" > 0< / span > < span class = "p" > ].< / span > < span class = "nx" > toUpperCase< / span > < span class = "p" > ()< / span > < span class = "o" > +< / span > < span class = "nx" > str< / span > < span class = "p" > .< / span > < span class = "nx" > slice< / span > < span class = "p" > (< / span > < span class = "mi" > 1< / span > < span class = "p" > );< / span >
2011-06-05 05:39:39 +00:00
< span class = "p" > };< / span > < / pre > < / div > < / td > < / tr > < tr id = "section-2" > < td class = "docs" > < div class = "pilwrap" > < a class = "pilcrow" href = "#section-2" > ¶ < / a > < / div > < p > Setup all stores as lazy-loaded getters.< / p > < / td > < td class = "code" > < div class = "highlight" > < pre > < span class = "nx" > fs< / span > < span class = "p" > .< / span > < span class = "nx" > readdirSync< / span > < span class = "p" > (< / span > < span class = "nx" > __dirname< / span > < span class = "o" > +< / span > < span class = "s1" > ' /stores' < / span > < span class = "p" > ).< / span > < span class = "nx" > forEach< / span > < span class = "p" > (< / span > < span class = "kd" > function< / span > < span class = "p" > (< / span > < span class = "nx" > file< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< span class = "kd" > var< / span > < span class = "nx" > store< / span > < span class = "o" > =< / span > < span class = "nx" > file< / span > < span class = "p" > .< / span > < span class = "nx" > replace< / span > < span class = "p" > (< / span > < span class = "s1" > ' .js' < / span > < span class = "p" > ,< / span > < span class = "s1" > ' ' < / span > < span class = "p" > ),< / span >
< span class = "nx" > name< / span > < span class = "o" > =< / span > < span class = "nx" > capitalize< / span > < span class = "p" > (< / span > < span class = "nx" > store< / span > < span class = "p" > );< / span >
< span class = "nx" > stores< / span > < span class = "p" > .< / span > < span class = "nx" > __defineGetter__< / span > < span class = "p" > (< / span > < span class = "nx" > name< / span > < span class = "p" > ,< / span > < span class = "kd" > function< / span > < span class = "p" > ()< / span > < span class = "p" > {< / span >
< span class = "k" > return< / span > < span class = "nx" > require< / span > < span class = "p" > (< / span > < span class = "s1" > ' ./stores/' < / span > < span class = "o" > +< / span > < span class = "nx" > store< / span > < span class = "p" > )[< / span > < span class = "nx" > name< / span > < span class = "p" > ];< / span >
< span class = "p" > });< / span >
< span class = "p" > });< / span > < / pre > < / div > < / td > < / tr > < tr id = "section-3" > < td class = "docs" > < div class = "pilwrap" > < a class = "pilcrow" href = "#section-3" > ¶ < / a > < / div > < h3 > function create (type, options)< / h3 >
2011-04-02 08:42:26 +00:00
< h4 > @type {string} Type of the nconf store to use.< / h4 >
< h4 > @options {Object} Options for the store instance.< / h4 >
< p > Creates a store of the specified < code > type< / code > using the
specified < code > options< / code > .< / p > < / td > < td class = "code" > < div class = "highlight" > < pre > < span class = "nx" > stores< / span > < span class = "p" > .< / span > < span class = "nx" > create< / span > < span class = "o" > =< / span > < span class = "kd" > function< / span > < span class = "p" > (< / span > < span class = "nx" > type< / span > < span class = "p" > ,< / span > < span class = "nx" > options< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< span class = "k" > return< / span > < span class = "k" > new< / span > < span class = "nx" > stores< / span > < span class = "p" > [< / span > < span class = "nx" > capitalize< / span > < span class = "p" > (< / span > < span class = "nx" > type< / span > < span class = "p" > .< / span > < span class = "nx" > toLowerCase< / span > < span class = "p" > ())](< / span > < span class = "nx" > options< / span > < span class = "p" > );< / span >
< span class = "p" > };< / span >
< / pre > < / div > < / td > < / tr > < / tbody > < / table > < / div > < / body > < / html >