diff options
author | Nick Van Doorn <vandoorn.nick@gmail.com> | 2019-01-19 21:58:05 -0800 |
---|---|---|
committer | Nick Van Doorn <vandoorn.nick@gmail.com> | 2019-01-19 21:58:05 -0800 |
commit | e8d64fb823a73d1297d151b4ebd0d05b86c97a0b (patch) | |
tree | 2a875c75b6e5270e082c73f5254669090d75990d /src | |
parent | 333fa3303788479d5df7b91996b68e0f7afa4413 (diff) |
Handle writing to root node
Diffstat (limited to 'src')
-rw-r--r-- | src/database.ts | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/database.ts b/src/database.ts index 70aecf4..9ac31ea 100644 --- a/src/database.ts +++ b/src/database.ts @@ -53,9 +53,13 @@ export class Database implements DatabaseInterface { } async write(path: string, toWrite: any): Promise<void> { - const pathParts = splitPath(path); - const writeTo = this.resolve(pathParts, false, 1); - writeTo[last(pathParts)] = toWrite; + if (path === "/") { + this.buff = toWrite; + } else { + const pathParts = splitPath(path); + const writeTo = this.resolve(pathParts, false, 1); + writeTo[last(pathParts)] = toWrite; + } await this.serialize(); } |