aboutsummaryrefslogtreecommitdiff
path: root/src/new_fields/Doc.ts
diff options
context:
space:
mode:
authorSam Wilkins <samuel_wilkins@brown.edu>2019-06-20 19:43:02 -0400
committerSam Wilkins <samuel_wilkins@brown.edu>2019-06-20 19:43:02 -0400
commita9467953c840bb38b70447861ac95731d3a62aa0 (patch)
tree41253983d924608ba5adc64826491f165574ce06 /src/new_fields/Doc.ts
parent9ea5aa5a5da3f098afbc92343c63bc21afaf4b1f (diff)
parenta40e7bb5e9d1256002083d7e3f3c4db60cd8e9df (diff)
merged with master
Diffstat (limited to 'src/new_fields/Doc.ts')
-rw-r--r--src/new_fields/Doc.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index de4bc4d5d..9bacf49ba 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -222,6 +222,16 @@ export namespace Doc {
return Array.from(results);
}
+ export function AddDocToList(target: Doc, key: string, doc: Doc, relativeTo?: Doc, before?: boolean) {
+ let list = Cast(target[key], listSpec(Doc));
+ if (list) {
+ let ind = relativeTo ? list.indexOf(relativeTo) : -1;
+ if (ind === -1) list.push(doc);
+ else list.splice(before ? ind : ind + 1, 0, doc);
+ }
+ return true;
+ }
+
export function MakeAlias(doc: Doc) {
if (!GetT(doc, "isPrototype", "boolean", true)) {
return Doc.MakeCopy(doc);