# YarnParser
## Installation
[Available in Hex](https://hex.pm/packages/yarn_parser), the package can be installed
by adding `yarn_parser` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:yarn_parser, "~> 0.3.1"}
]
end
```
## Usage
```elixir
iex> input =
"""
# Some comment
# yarn lockfile v1
key1, key2:
val1 true
subkey1:
val2 123
"""
iex> {:ok, parsed} = YarnParser.decode(input)
iex> parsed
%YarnParser.YarnLock{
metadata: %{
"version" => 1
}
dependencies: {
"key1" => %{
"val1" => true,
"subkey1" => %{
"val2" => 123
}
},
"key2" => %{
"val1" => true,
"subkey1" => %{
"val2" => 123
}
}
}
}
iex> YarnParser.get_version(parsed)
1
iex> YarnParser.encode(parsed)
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
key1, key2:
subkey1:
val2 123
val1 true
```
## TODO
- [ ] Parse with merge conflicts
- [ ] Improve error messages
- [ ] Improve test suite
- [ ] Implement encoder for v2 lockfiles