aboutsummaryrefslogtreecommitdiff
path: root/packages/server/src/git/blob.ts
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2021-07-26 23:56:53 +0200
committerHampusM <hampus@hampusmat.com>2021-07-26 23:56:53 +0200
commit09ff261f156a8599d45c1496fe246ded6e035191 (patch)
tree306f79709da372b562eca70d356fa25afcde1f95 /packages/server/src/git/blob.ts
parentc575df758b269db8e05c597d5870e948771d4c2b (diff)
Added backend TSDoc/JSDoc comments & refactored a tiny bit
Diffstat (limited to 'packages/server/src/git/blob.ts')
-rw-r--r--packages/server/src/git/blob.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/packages/server/src/git/blob.ts b/packages/server/src/git/blob.ts
index ef9f9ab..eebd2d4 100644
--- a/packages/server/src/git/blob.ts
+++ b/packages/server/src/git/blob.ts
@@ -2,21 +2,38 @@ import { BlobError, createError } from "./error";
import { Tree } from "./tree";
import { BlobTreeEntry } from "./tree_entry";
+/**
+ * A representation of a blob
+ */
export class Blob {
private _tree_entry: BlobTreeEntry;
public path;
+ /**
+ * @param entry - A tree entry that's a blob
+ * @param path - A path
+ */
constructor(entry: BlobTreeEntry, path: string) {
this._tree_entry = entry;
this.path = path;
}
+ /**
+ * Returns the blob's content
+ */
public async content(): Promise<string> {
return this._tree_entry.content();
}
+ /**
+ * Returns a blob from a path in a tree
+ *
+ * @param tree - The tree to look in
+ * @param path - A path to a blob
+ * @returns An instance of a blob
+ */
public static async fromPath(tree: Tree, path: string): Promise<Blob> {
const entry = await tree.find(path);