Skip to content

json-crdt-patch schema recursive types #922

@streamich

Description

@streamich

Add ability to specify recursive types using a function wrapper

import {s} from 'json-joy/lib/json-crdt-patch';

const User = s.obj({
  id: s.con(''),
  name: s.str(''),
},
// Second object are optional fields
{
  friend: () => User,
});

type UserType = {id: string, name: string, friend?: User};

Binary tree example:

const Node = s.obj({
  key: s.str(''),
  value: s.str(''),
},
{
  left: () => Node,
  right: () => Node,
});

type UserType = {id: string, name: string, friend?: User};

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions