{\bfseries{This module will be deprecated once npm v7 is released. Please do not rely on it more than absolutely necessary (ie, only if you are depending on it for use with npm v6 internal dependencies).}}

\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10364}{}\doxysection{figgy-\/pudding $<$a href=\char`\"{}https\+://npm.\+im/figgy-\/pudding\char`\"{}$>$$<$img src=\char`\"{}https\+://img.\+shields.\+io/npm/v/figgy-\/pudding.\+svg\char`\"{} alt=\char`\"{}npm version\char`\"{}/$>$$<$/a$>$ $<$a href=\char`\"{}https\+://npm.\+im/figgy-\/pudding\char`\"{}$>$$<$img src=\char`\"{}https\+://img.\+shields.\+io/npm/l/figgy-\/pudding.\+svg\char`\"{} alt=\char`\"{}license\char`\"{}/$>$$<$/a$>$ $<$a href=\char`\"{}https\+://travis-\/ci.\+org/npm/figgy-\/pudding\char`\"{}$>$$<$img src=\char`\"{}https\+://img.\+shields.\+io/travis/npm/figgy-\/pudding.\+svg\char`\"{} alt=\char`\"{}\+Travis\char`\"{}/$>$$<$/a$>$ $<$a href=\char`\"{}https\+://coveralls.\+io/github/npm/figgy-\/pudding?branch=latest\char`\"{}$>$$<$img src=\char`\"{}https\+://coveralls.\+io/repos/github/npm/figgy-\/pudding/badge.\+svg?branch=latest\char`\"{} alt=\char`\"{}\+Coverage Status\char`\"{}/$>$$<$/a$>$}\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10364}
\href{https://github.com/npm/figgy-pudding}{\texttt{ {\ttfamily figgy-\/pudding}}} is a small Java\+Script library for managing and composing cascading options objects -- hiding what needs to be hidden from each layer, without having to do a lot of manual munging and passing of options.\hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10365}{}\doxysubsubsection{The God Object is Dead!}\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10365}
\hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10366}{}\doxysubsubsection{Now Bring Us Some Figgy Pudding!}\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10366}
\hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10367}{}\doxysubsection{Install}\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10367}
{\ttfamily \$ npm install figgy-\/pudding}\hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10368}{}\doxysubsection{Table of Contents}\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10368}

\begin{DoxyItemize}
\item \href{\#example}{\texttt{ Example}}
\item \href{\#features}{\texttt{ Features}}
\item \href{\#api}{\texttt{ API}}
\begin{DoxyItemize}
\item \href{\#figgy-pudding}{\texttt{ {\ttfamily figgy\+Pudding(spec)}}}
\item \href{\#pudding-factory}{\texttt{ {\ttfamily Pudding\+Factory(values)}}}
\begin{DoxyItemize}
\item \href{\#opts-get}{\texttt{ {\ttfamily opts.\+get()}}}
\item \href{\#opts-concat}{\texttt{ {\ttfamily opts.\+concat()}}}
\item \href{\#opts-to-json}{\texttt{ {\ttfamily opts.\+to\+JSON()}}}
\item \href{\#opts-for-each}{\texttt{ {\ttfamily opts.\+for\+Each()}}}
\item \href{\#opts-symbol-iterator}{\texttt{ {\ttfamily opts\mbox{[}Symbol.\+iterator\mbox{]}()}}}
\item \href{\#opts-entries}{\texttt{ {\ttfamily opts.\+entries()}}}
\item \href{\#opts-keys}{\texttt{ {\ttfamily opts.\+keys()}}}
\item \href{\#opts-values}{\texttt{ {\ttfamily opts.\+value()}}}
\end{DoxyItemize}
\end{DoxyItemize}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10369}{}\doxysubsubsection{Example}\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10369}

\begin{DoxyCode}{0}
\DoxyCodeLine{// print-\/package.js}
\DoxyCodeLine{const fetch = require('./fetch.js')}
\DoxyCodeLine{const puddin = require('figgy-\/pudding')}
\DoxyCodeLine{}
\DoxyCodeLine{const PrintOpts = puddin(\{}
\DoxyCodeLine{  json: \{ default: false \}}
\DoxyCodeLine{\})}
\DoxyCodeLine{}
\DoxyCodeLine{async function printPkg (name, opts) \{}
\DoxyCodeLine{  // Expected pattern is to call this in every interface function. If `opts` is}
\DoxyCodeLine{  // not passed in, it will automatically create an (empty) object for it.}
\DoxyCodeLine{  opts = PrintOpts(opts)}
\DoxyCodeLine{  const uri = `https://registry.npmjs.com/\$\{name\}`}
\DoxyCodeLine{  const res = await fetch(uri, opts.concat(\{}
\DoxyCodeLine{    // Add or override any passed-\/in configs and pass them down.}
\DoxyCodeLine{    log: customLogger}
\DoxyCodeLine{  \}))}
\DoxyCodeLine{  // The following would throw an error, because it's not in PrintOpts:}
\DoxyCodeLine{  // console.log(opts.log)}
\DoxyCodeLine{  if (opts.json) \{}
\DoxyCodeLine{    return res.json()}
\DoxyCodeLine{  \} else \{}
\DoxyCodeLine{    return res.text()}
\DoxyCodeLine{  \}}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(await printPkg('figgy', \{}
\DoxyCodeLine{  // Pass in *all* configs at the toplevel, as a regular object.}
\DoxyCodeLine{  json: true,}
\DoxyCodeLine{  cache: './tmp-\/cache'}
\DoxyCodeLine{\})) }

\end{DoxyCode}



\begin{DoxyCode}{0}
\DoxyCodeLine{// fetch.js}
\DoxyCodeLine{const puddin = require('figgy-\/pudding')}
\DoxyCodeLine{}
\DoxyCodeLine{const FetchOpts = puddin(\{}
\DoxyCodeLine{  log: \{ default: require('npmlog') \},}
\DoxyCodeLine{  cache: \{\}}
\DoxyCodeLine{\})}
\DoxyCodeLine{}
\DoxyCodeLine{module.exports = async function (..., opts) \{}
\DoxyCodeLine{  opts = FetchOpts(opts)}
\DoxyCodeLine{\} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10370}{}\doxysubsubsection{Features}\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10370}

\begin{DoxyItemize}
\item hide options from layer that didn\textquotesingle{}t ask for it
\item shared multi-\/layer options
\item make sure {\ttfamily opts} argument is available
\item transparent key access like normal keys, through a Proxy. No need for$<$tt$>$.\+get()!
\item default values
\item key aliases
\item arbitrary key filter functions
\item key/value iteration
\item serialization
\item 100\% test coverage using {\ttfamily tap -\/-\/100}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10371}{}\doxysubsubsection{API}\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10371}
\hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10372}{}\doxyparagraph{$<$a name=\char`\"{}figgy-\/pudding\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ figgy\+Pudding(\{ key\+: \{ default\+: val \} $\vert$ String \}, \mbox{[}opts\mbox{]}) -\/$>$ Pudding\+Factory$<$/tt$>$}\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10372}
Defines an Options constructor that can be used to collect only the needed options.

An optional {\ttfamily default} property for specs can be used to specify default values if nothing was passed in.

If the value for a spec is a string, it will be treated as an alias to that other key.

\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10373}%
\Hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10373}%
\doxysubparagraph*{Example}


\begin{DoxyCode}{0}
\DoxyCodeLine{const MyAppOpts = figgyPudding(\{}
\DoxyCodeLine{  lg: 'log',}
\DoxyCodeLine{  log: \{}
\DoxyCodeLine{    default: () => require('npmlog')}
\DoxyCodeLine{  \},}
\DoxyCodeLine{  cache: \{\}}
\DoxyCodeLine{\}) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10374}{}\doxyparagraph{$<$a name=\char`\"{}pudding-\/factory\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ Pudding\+Factory(...\+providers) -\/$>$ Figgy\+Pudding\{\}$<$/tt$>$}\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10374}
Instantiates an options object defined by {\ttfamily figgy\+Pudding()}, which uses {\ttfamily providers}, in order, to find requested properties.

Each provider can be either a plain object, a {\ttfamily Map}-\/like object (that is, one with a {\ttfamily .get()} method) or another figgy\+Pudding {\ttfamily Opts} object.

When nesting {\ttfamily Opts} objects, their properties will not become available to the new object, but any further nested {\ttfamily Opts} that reference that property {\itshape will} be able to read from their grandparent, as long as they define that key. Default values for nested {\ttfamily Opts} parents will be used, if found.

\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10375}%
\Hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10375}%
\doxysubparagraph*{Example}


\begin{DoxyCode}{0}
\DoxyCodeLine{const ReqOpts = figgyPudding(\{}
\DoxyCodeLine{  follow: \{\}}
\DoxyCodeLine{\})}
\DoxyCodeLine{}
\DoxyCodeLine{const opts = ReqOpts(\{}
\DoxyCodeLine{  follow: true,}
\DoxyCodeLine{  log: require('npmlog')}
\DoxyCodeLine{\})}
\DoxyCodeLine{}
\DoxyCodeLine{opts.follow // => true}
\DoxyCodeLine{opts.log // => Error: ReqOpts does not define `log`}
\DoxyCodeLine{}
\DoxyCodeLine{const MoreOpts = figgyPudding(\{}
\DoxyCodeLine{  log: \{\}}
\DoxyCodeLine{\})}
\DoxyCodeLine{MoreOpts(opts).log // => npmlog object (passed in from original plain obj)}
\DoxyCodeLine{MoreOpts(opts).follow // => Error: MoreOpts does not define `follow` }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10376}{}\doxyparagraph{$<$a name=\char`\"{}opts-\/get\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ opts.\+get(key) -\/$>$ Value$<$/tt$>$}\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10376}
Gets a value from the options object.

\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10377}%
\Hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10377}%
\doxysubparagraph*{Example}


\begin{DoxyCode}{0}
\DoxyCodeLine{const opts = MyOpts(config)}
\DoxyCodeLine{opts.get('foo') // value of `foo`}
\DoxyCodeLine{opts.foo // Proxy-\/based access through `.get()` }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10378}{}\doxyparagraph{$<$a name=\char`\"{}opts-\/concat\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ opts.\+concat(...\+more\+Providers) -\/$>$ Figgy\+Pudding\{\}$<$/tt$>$}\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10378}
Creates a new opts object of the same type as {\ttfamily opts} with additional providers. Providers further to the right shadow providers to the left, with properties in the original {\ttfamily opts} being shadows by the new providers.

\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10379}%
\Hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10379}%
\doxysubparagraph*{Example}


\begin{DoxyCode}{0}
\DoxyCodeLine{const opts = MyOpts(\{x: 1\})}
\DoxyCodeLine{opts.get('x') // 1}
\DoxyCodeLine{opts.concat(\{x: 2\}).get('x') // 2}
\DoxyCodeLine{opts.get('x') // 1 (original opts object left intact) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10380}{}\doxyparagraph{$<$a name=\char`\"{}opts-\/to-\/json\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ opts.\+to\+JSON() -\/$>$ Value$<$/tt$>$}\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10380}
Converts {\ttfamily opts} to a plain, JSON-\/stringifiable Java\+Script value. Used internally by Java\+Script to get {\ttfamily JSON.\+stringify()} working.

Only keys that are readable by the current pudding type will be serialized.

\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10381}%
\Hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10381}%
\doxysubparagraph*{Example}


\begin{DoxyCode}{0}
\DoxyCodeLine{const opts = MyOpts(\{x: 1\})}
\DoxyCodeLine{opts.toJSON() // \{x: 1\}}
\DoxyCodeLine{JSON.stringify(opts) // '\{"{}x"{}:1\}' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10382}{}\doxyparagraph{$<$a name=\char`\"{}opts-\/for-\/each\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ opts.\+for\+Each((value, key, opts) =$>$ \{\}, this\+Arg) -\/$>$ undefined$<$/tt$>$}\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10382}
Iterates over the values of {\ttfamily opts}, limited to the keys readable by the current pudding type. {\ttfamily this\+Arg} will be used to set the {\ttfamily this} argument when calling the {\ttfamily fn}.

\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10383}%
\Hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10383}%
\doxysubparagraph*{Example}


\begin{DoxyCode}{0}
\DoxyCodeLine{const opts = MyOpts(\{x: 1, y: 2\})}
\DoxyCodeLine{opts.forEach((value, key) => console.log(key, '=', value)) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10384}{}\doxyparagraph{$<$a name=\char`\"{}opts-\/entries\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ opts.\+entries() -\/$>$ Iterator$<$\mbox{[}\mbox{[}key, value\mbox{]}, ...\mbox{]}$>$$<$/tt$>$}\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10384}
Returns an iterator that iterates over the keys and values in {\ttfamily opts}, limited to the keys readable by the current pudding type. Each iteration returns an array of {\ttfamily \mbox{[}key, value\mbox{]}}.

\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10385}%
\Hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10385}%
\doxysubparagraph*{Example}


\begin{DoxyCode}{0}
\DoxyCodeLine{const opts = MyOpts(\{x: 1, y: 2\})}
\DoxyCodeLine{[...opts(\{x: 1, y: 2\}).entries()] // [['x', 1], ['y', 2]] }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10386}{}\doxyparagraph{$<$a name=\char`\"{}opts-\/symbol-\/iterator\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ opts\mbox{[}\+Symbol.\+iterator\mbox{]}() -\/$>$ Iterator$<$\mbox{[}\mbox{[}key, value\mbox{]}, ...\mbox{]}$>$$<$/tt$>$}\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10386}
Returns an iterator that iterates over the keys and values in {\ttfamily opts}, limited to the keys readable by the current pudding type. Each iteration returns an array of {\ttfamily \mbox{[}key, value\mbox{]}}. Makes puddings work natively with JS iteration mechanisms.

\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10387}%
\Hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10387}%
\doxysubparagraph*{Example}


\begin{DoxyCode}{0}
\DoxyCodeLine{const opts = MyOpts(\{x: 1, y: 2\})}
\DoxyCodeLine{[...opts(\{x: 1, y: 2\})] // [['x', 1], ['y', 2]]}
\DoxyCodeLine{for (let [key, value] of opts(\{x: 1, y: 2\})) \{}
\DoxyCodeLine{  console.log(key, '=', value)}
\DoxyCodeLine{\} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10388}{}\doxyparagraph{$<$a name=\char`\"{}opts-\/keys\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ opts.\+keys() -\/$>$ Iterator$<$\mbox{[}key, ...\mbox{]}$>$$<$/tt$>$}\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10388}
Returns an iterator that iterates over the keys in {\ttfamily opts}, limited to the keys readable by the current pudding type.

\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10389}%
\Hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10389}%
\doxysubparagraph*{Example}


\begin{DoxyCode}{0}
\DoxyCodeLine{const opts = MyOpts(\{x: 1, y: 2\})}
\DoxyCodeLine{[...opts(\{x: 1, y: 2\}).keys()] // ['x', 'y'] }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10390}{}\doxyparagraph{$<$a name=\char`\"{}opts-\/values\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ opts.\+values() -\/$>$ Iterator$<$\mbox{[}value, ...\mbox{]}$>$$<$/tt$>$}\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10390}
Returns an iterator that iterates over the values in {\ttfamily opts}, limited to the keys readable by the current pudding type.

\label{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10391}%
\Hypertarget{md_sfcode_node_modules_figgy_pudding_README_autotoc_md10391}%
\doxysubparagraph*{Example}

\textquotesingle{} 
\begin{DoxyCode}{0}
\DoxyCodeLine{const opts = MyOpts(\{x: 1, y: 2\})}
\DoxyCodeLine{[...opts(\{x: 1, y: 2\}).values()] // [1, 2] }

\end{DoxyCode}
 