1
1
mirror of https://github.com/wader/fq.git synced 2024-09-20 08:18:51 +03:00
fq/format/bencode/bencode.jq
Mattias Wadman 0863374f8c doc: Correct bencode spec URL
Also rename _tojq value_sep to object_sep and fix formats_diagram.jq to use tomd5
2022-06-13 18:49:34 +02:00

18 lines
486 B
Plaintext

def _bencode_torepr:
if .type == "string" then .value | tovalue
elif .type == "integer" then .value | tovalue
elif .type == "list" then .values | map(_bencode_torepr)
elif .type == "dictionary" then
( .pairs
| map({key: (.key | _bencode_torepr), value: (.value | _bencode_torepr)})
| from_entries
)
else error("unknown type \(.type)")
end;
def _bencode__help:
{ links: [
{url: "https://wiki.theory.org/BitTorrentSpecification#Bencoding"}
]
};