corestore 6.9.0 → 6.10.0

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 +9 -0
  2. package/package.json +3 -2
package/index.js CHANGED
@@ -43,11 +43,20 @@ module.exports = class Corestore extends ReadyResource {
43
43
 
44
44
  this._findingPeersCount = 0
45
45
  this._findingPeers = []
46
+ this._isCorestore = true
46
47
 
47
48
  if (this._namespace.byteLength !== 32) throw new Error('Namespace must be a 32-byte Buffer or Uint8Array')
48
49
  this.ready().catch(safetyCatch)
49
50
  }
50
51
 
52
+ static isCorestore (obj) {
53
+ return !!(typeof obj === 'object' && obj && obj._isCorestore)
54
+ }
55
+
56
+ static from (storage, opts) {
57
+ return this.isCorestore(storage) ? storage : new this(storage, opts)
58
+ }
59
+
51
60
  // for now just release the lock...
52
61
  async suspend () {
53
62
  if (this._root !== this) return this._root.suspend()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "corestore",
3
- "version": "6.9.0",
3
+ "version": "6.10.0",
4
4
  "description": "A Hypercore factory that simplifies managing collections of cores.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -26,7 +26,8 @@
26
26
  "devDependencies": {
27
27
  "brittle": "^3.0.0",
28
28
  "random-access-memory": "^6.0.0",
29
- "standardx": "^7.0.0"
29
+ "standard": "^17.0.0",
30
+ "test-tmp": "^1.0.2"
30
31
  },
31
32
  "dependencies": {
32
33
  "b4a": "^1.3.1",