Infer the owner of a path based on the owner of its nearest existing parent\hypertarget{md_sfcode_node_modules_infer_owner_README_autotoc_md12727}{}\doxysection{USAGE}\label{md_sfcode_node_modules_infer_owner_README_autotoc_md12727}

\begin{DoxyCode}{0}
\DoxyCodeLine{const inferOwner = require('infer-\/owner')}
\DoxyCodeLine{}
\DoxyCodeLine{inferOwner('/some/cache/folder/file').then(owner => \{}
\DoxyCodeLine{  // owner is \{uid, gid\} that should be attached to}
\DoxyCodeLine{  // the /some/cache/folder/file, based on ownership}
\DoxyCodeLine{  // of /some/cache/folder, /some/cache, /some, or /,}
\DoxyCodeLine{  // whichever is the first to exist}
\DoxyCodeLine{\})}
\DoxyCodeLine{}
\DoxyCodeLine{// same, but not async}
\DoxyCodeLine{const owner = inferOwner.sync('/some/cache/folder/file')}
\DoxyCodeLine{}
\DoxyCodeLine{// results are cached!  to reset the cache (eg, to change}
\DoxyCodeLine{// permissions for whatever reason), do this:}
\DoxyCodeLine{inferOwner.clearCache() }

\end{DoxyCode}


This module endeavors to be as performant as possible. Parallel requests for ownership of the same path will only stat the directories one time.\hypertarget{md_sfcode_node_modules_infer_owner_README_autotoc_md12728}{}\doxysection{API}\label{md_sfcode_node_modules_infer_owner_README_autotoc_md12728}

\begin{DoxyItemize}
\item {\ttfamily infer\+Owner(path) -\/$>$ Promise$<$\{ uid, gid \}$>$}

If the path exists, return its uid and gid. If it does not, look to its parent, then its grandparent, and so on.
\item {\ttfamily infer\+Owner(path) -\/$>$ \{ uid, gid \}}

Sync form of {\ttfamily infer\+Owner(path)}.
\item {\ttfamily infer\+Owner.\+clear\+Cache()}

Delete all cached ownership information and in-\/flight tracking. 
\end{DoxyItemize}