Comparing version 6.5.3 to 6.5.4
@@ -233,3 +233,3 @@ const Hyperbee = require('hyperbee') | ||
if (!b4a.equals(this.pendingIndexers[i], h.key)) continue | ||
this._updateIndexer(h.key, h.length, false, i) | ||
this._updateIndexer(h.key, h.length, true, i) | ||
return true | ||
@@ -247,6 +247,6 @@ } | ||
_updateIndexer (key, length, isRemoved, i) { | ||
_updateIndexer (key, length, isIndexer, i) { | ||
const hex = b4a.toString(key, 'hex') | ||
if (isRemoved) { | ||
if (!isIndexer) { | ||
const existing = this._indexerMap.get(hex) | ||
@@ -265,3 +265,3 @@ if (existing) { | ||
if (!isRemoved && length === 0) { | ||
if (length === 0) { | ||
if (i >= this.pendingIndexers.length) this.pendingIndexers.push(key) | ||
@@ -296,2 +296,3 @@ return | ||
let wasTracked = false | ||
let wasIndexer = false | ||
@@ -317,2 +318,3 @@ if (length === 0) { // a bit hacky atm due to cas limitations... | ||
if (!o.isRemoved) wasTracked = true | ||
if (o.isIndexer) wasIndexer = true | ||
@@ -327,3 +329,3 @@ if (length === 0 && o.length) length = o.length | ||
if (isIndexer) this._updateIndexer(key, length, false, 0) | ||
if (wasIndexer || isIndexer) this._updateIndexer(key, length, isIndexer, 0) | ||
} | ||
@@ -339,3 +341,3 @@ | ||
if (isIndexer) this._updateIndexer(key, null, true, 0) | ||
if (isIndexer) this._updateIndexer(key, null, false, 0) | ||
@@ -342,0 +344,0 @@ let wasTracked = false |
@@ -23,3 +23,2 @@ const Linearizer = require('./linearizer') | ||
this.node = null | ||
this.isIndexer = false | ||
this.isActiveIndexer = false | ||
@@ -26,0 +25,0 @@ this.available = length |
{ | ||
"name": "autobase", | ||
"version": "6.5.3", | ||
"version": "6.5.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -10,6 +10,8 @@ # Autobase | ||
```js | ||
const RAM = require('random-access-memory') | ||
const Corestore = require('corestore') | ||
const Autobase = require('autobase') | ||
const local = new Autobase(new Corestore, remote.key, { apply, open }) | ||
const store = new Corestore(RAM.reusable()) | ||
const local = new Autobase(store, remote.key, { apply, open }) | ||
await local.ready() | ||
@@ -53,3 +55,3 @@ | ||
await view.append(value) | ||
} | ||
} | ||
} | ||
@@ -64,3 +66,3 @@ ``` | ||
As new causal information comes in, existing nodes may be reordered. Any changes to the view will be undone and reapplied ontop of the new ordering. | ||
As new causal information comes in, existing nodes may be reordered. Any changes to the view will be undone and reapplied on top of the new ordering. | ||
@@ -89,3 +91,3 @@ ### Indexed Length | ||
*IMPORTANT*: Autobase messages may be reordered as new data becomes available. Updates will undone and reapplied internally, but this can _only_ work if the view is an instance of a `LinearizedCore`. It is important that any data structures touched by the `apply` function have been derived from the `store` object passed to the `open` handler. If any external data structures are used, these updates will not be correctly undone. | ||
*IMPORTANT*: Autobase messages may be reordered as new data becomes available. Updates will be undone and reapplied internally, but this can _only_ work if the view is built with an instance of an `Autocore`. It is important that any data structures touched by the `apply` function have been derived from the `store` object passed to the `open` handler. If any external data structures are used, these updates will not be correctly undone. | ||
@@ -138,3 +140,3 @@ ## API | ||
#### `const core = Autobase.getLocalCore(store)` | ||
#### `const core = Autobase.getLocalCore(store, handlers, encryptionKey)` | ||
@@ -147,24 +149,20 @@ Generate a local core to be used for an Autobase. | ||
### `LinearizedStore` | ||
### `AutoStore` | ||
Each autobase creates a `LinearizedStore` which is used to create views. The store is passed to the `open` function. | ||
Each autobase creates a `AutoStore` which is used to create views. The store is passed to the `open` function. | ||
#### `const core = await store.get(name || { name, valueEncoding })` | ||
Get a new `LinearizedCore` from the store. `name` shuold be passed as a string. | ||
Load a `Autocore` by name (passed as `name`) and return a `AutocoreSession` for it. `name` should be passed as a string. | ||
#### `const core = await store.update()` | ||
#### `await store.ready()` | ||
Wait until all cores are ready. | ||
### `LinearizedCore` | ||
### `AutocoreSession` | ||
#### `const core = await store.get(name || { name, valueEncoding })` | ||
Instantiate a new core. A string may be passed directly or otherwise an object can be passed to define `valueEncoding` | ||
Create or load a core and return a session for it. A string may be passed directly or otherwise an object can be passed to define `valueEncoding` | ||
#### `core.name` | ||
The name of the core. | ||
#### `core.indexedLength` | ||
@@ -171,0 +169,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
187859
5067
181