braid-blob 0.0.83 → 0.0.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +9 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -452,6 +452,15 @@ function create_braid_blob() {
|
|
|
452
452
|
return keys
|
|
453
453
|
}
|
|
454
454
|
|
|
455
|
+
// exists() checks whether a key is present, with an optional callback
|
|
456
|
+
// to process the result atomically (same pattern as list())
|
|
457
|
+
braid_blob.exists = async (key, cb) => {
|
|
458
|
+
await braid_blob.init()
|
|
459
|
+
var exists = !!braid_blob.meta_db.prepare(`SELECT 1 FROM meta WHERE key = ?`).get(key)
|
|
460
|
+
if (cb) cb(exists)
|
|
461
|
+
return exists
|
|
462
|
+
}
|
|
463
|
+
|
|
455
464
|
braid_blob.init = async () => {
|
|
456
465
|
// We only want to initialize once
|
|
457
466
|
var init_p = real_init()
|