File: bencode.jq

package info (click to toggle)
fq 0.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 106,624 kB
  • sloc: xml: 2,835; makefile: 250; sh: 241; exp: 57; ansic: 21
file content (11 lines) | stat: -rw-r--r-- 368 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
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;