Parse and/or write {\ttfamily yarn.\+lock} files\hypertarget{md_sfcode_node_modules__yarnpkg_lockfile_README_autotoc_md2322}{}\doxysection{Usage Examples}\label{md_sfcode_node_modules__yarnpkg_lockfile_README_autotoc_md2322}

\begin{DoxyCode}{0}
\DoxyCodeLine{const fs = require('fs');}
\DoxyCodeLine{const lockfile = require('@yarnpkg/lockfile');}
\DoxyCodeLine{// or (es6)}
\DoxyCodeLine{import fs from 'fs';}
\DoxyCodeLine{import * as lockfile from '@yarnpkg/lockfile';}
\DoxyCodeLine{}
\DoxyCodeLine{let file = fs.readFileSync('yarn.lock', 'utf8');}
\DoxyCodeLine{let json = lockfile.parse(file);}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(json);}
\DoxyCodeLine{}
\DoxyCodeLine{let fileAgain = lockfile.stringify(json);}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(fileAgain); }

\end{DoxyCode}
 