From d7fff434fe8ded7d2b380e03e5d9a906f051672a Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Tue, 8 Oct 2024 23:32:34 +0200 Subject: [PATCH] Expose drive.snapshot() --- README.md | 4 ++++ index.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index c5c91c57..47746243 100644 --- a/README.md +++ b/README.md @@ -315,6 +315,10 @@ Downloads the blobs corresponding to all entries in the drive at paths prefixed Get a read-only snapshot of a previous version. +#### `const snapshot = drive.snapshot()` + +Shorthand for getting a checkout for the current version. + #### `const stream = drive.diff(version, folder, [options])` Efficiently create a stream of the shallow changes to `folder` between `version` and `drive.version`. diff --git a/index.js b/index.js index 99b4d645..ab4da3a6 100644 --- a/index.js +++ b/index.js @@ -158,6 +158,10 @@ module.exports = class Hyperdrive extends ReadyResource { return this._makeCheckout(this.db.checkout(version)) } + snapshot () { + return this._makeCheckout(this.db.snapshot()) + } + batch () { return new Hyperdrive(this.corestore, this.key, { onwait: this._onwait,