def unique.go

bend-kit-json@0.7.0.0 · json.bend:826

import bend-kit-json@0.7.0.0/json.bend as Json
import Base

826# The value back, whether every object nested inside it has unique keys, and
827# the fingerprints of v's own keys when v is an object. The caller that holds
828# the whole object checks those.
829def unique.go(v: Val) -> Val & Bool & List<&2, List<&2, U32>>:
830  match v:
831    case Null{}:
832      (Null{}, True{}, Nil{})
833    case Flag{on}:
834      (Flag{on}, True{}, Nil{})
835    case Num{s}:
836      (Num{s}, True{}, Nil{})
837    case Str{s}:
838      (Str{s}, True{}, Nil{})
839    case Arr{Nil{}}:
840      (Arr{Nil{}}, True{}, Nil{})
841    case Arr{Con{head, tail}}:
842      unique.array(unique.go(head), unique.go(Arr{tail}))
843    case Obj{Nil{}}:
844      (Obj{Nil{}}, True{}, Nil{})
845    case Obj{(key, head) <> tail}:
846      unique.object(key, unique.go(head), unique.go(Obj{tail}))

Uses (8)

Used by (1)