hypercore-storage 0.0.25 → 0.0.26

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.
Files changed (2) hide show
  1. package/index.js +8 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -358,7 +358,7 @@ module.exports = class CoreStorage {
358
358
  return new HypercoreStorage(this, discoveryKey, core, data, null)
359
359
  }
360
360
 
361
- async create ({ key, manifest, keyPair, encryptionKey, discoveryKey }) {
361
+ async create ({ key, manifest, keyPair, encryptionKey, discoveryKey, userData }) {
362
362
  await this.mutex.write.lock()
363
363
 
364
364
  try {
@@ -390,7 +390,7 @@ module.exports = class CoreStorage {
390
390
  const batch = new WriteBatch(storage, write)
391
391
 
392
392
  initialiseCoreInfo(batch, { key, manifest, keyPair, encryptionKey })
393
- initialiseCoreData(batch)
393
+ initialiseCoreData(batch, { userData })
394
394
 
395
395
  await batch.flush()
396
396
  return storage
@@ -745,6 +745,11 @@ function initialiseCoreInfo (db, { key, manifest, keyPair, encryptionKey }) {
745
745
  if (encryptionKey) db.setEncryptionKey(encryptionKey)
746
746
  }
747
747
 
748
- function initialiseCoreData (db) {
748
+ function initialiseCoreData (db, { userData } = {}) {
749
749
  db.setDataInfo({ version: 0 })
750
+ if (userData) {
751
+ for (const { key, value } of userData) {
752
+ db.setUserData(key, value)
753
+ }
754
+ }
750
755
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore-storage",
3
- "version": "0.0.25",
3
+ "version": "0.0.26",
4
4
  "main": "index.js",
5
5
  "files": [
6
6
  "index.js",