diff options
| author | Tyler Schicke <tyler_schicke@brown.edu> | 2019-04-24 22:36:11 -0400 |
|---|---|---|
| committer | Tyler Schicke <tyler_schicke@brown.edu> | 2019-04-24 22:36:11 -0400 |
| commit | 70a889c103139e43acae84e1a5a91240b3d195c2 (patch) | |
| tree | 4e780e254698844306f6918dc21120cf5ebae17e /src/new_fields/Doc.ts | |
| parent | a4e2e38fbe60d48fe1d211aec9b4e6bd99c815c1 (diff) | |
Almost all of schema view
Diffstat (limited to 'src/new_fields/Doc.ts')
| -rw-r--r-- | src/new_fields/Doc.ts | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index cce578b60..bd10e5474 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -4,7 +4,7 @@ import { autoObject, SerializationHelper, Deserializable } from "../client/util/ import { Utils } from "../Utils"; import { DocServer } from "../client/DocServer"; import { setter, getter, getField } from "./util"; -import { Cast, ToConstructor, PromiseValue } from "./Types"; +import { Cast, ToConstructor, PromiseValue, FieldValue } from "./Types"; export type FieldId = string; export const HandleUpdate = Symbol("HandleUpdate"); @@ -93,6 +93,15 @@ export namespace Doc { proto[key] = value; } } + export function GetAllPrototypes(doc: Doc): Doc[] { + const protos: Doc[] = []; + let d: Opt<Doc> = doc; + while (d) { + protos.push(d); + d = FieldValue(d.proto); + } + return protos; + } export function assign<K extends string>(doc: Doc, fields: Partial<Record<K, Opt<Field>>>) { for (const key in fields) { if (fields.hasOwnProperty(key)) { |
