import assert from 'assert'
-import Lazy from './Lazy.mjs'
+import LazyValue from './LazyValue.mjs'
-class LazyArray extends Lazy {
+class LazyArray extends LazyValue {
constructor(transaction, ptr_len, array) {
super(transaction, ptr_len)
this.array = array || []
assert(
typeof value !== 'object' ||
value === null ||
- (value instanceof Lazy && value.transaction === this.transaction)
+ (value instanceof LazyValue && value.transaction === this.transaction)
)
this.ptr_len = null // mark dirty
this.array[key] = value
async commit() {
for (let i = 0; i < this.length; ++i) {
let value = this.array[i]
- if (value instanceof Lazy) {
+ if (value instanceof LazyValue) {
if (await value.commit())
this.ptr_len = null // mark dirty
this.array[i] = value.ptr_len
import assert from 'assert'
-import Lazy from './Lazy.mjs'
+import LazyValue from './LazyValue.mjs'
-class LazyObject extends Lazy {
+class LazyObject extends LazyValue {
constructor(transaction, ptr_len, object) {
super(transaction, ptr_len)
this.object = object || {}
assert(
typeof value !== 'object' ||
value === null ||
- (value instanceof Lazy && value.transaction === this.transaction)
+ (value instanceof LazyValue && value.transaction === this.transaction)
)
this.ptr_len = null // mark dirty
this.object[key] = value
async commit() {
for (let i in this.object) {
let value = this.object[i]
- if (value instanceof Lazy) {
+ if (value instanceof LazyValue) {
if (await value.commit())
this.ptr_len = null // mark dirty
this.object[i] = value.ptr_len
import assert from 'assert'
import Transaction from './Transaction.mjs'
-class Lazy {
+class LazyValue {
constructor(transaction, ptr_len) {
assert(transaction instanceof Transaction)
this.transaction = transaction
}
}
-export default Lazy
+export default LazyValue
import assert from 'assert'
import fsPromises from 'fs/promises'
import Database from './Database.mjs'
-import Lazy from './Lazy.mjs'
+import LazyValue from './LazyValue.mjs'
import LazyArray from './LazyArray.mjs'
import LazyObject from './LazyObject.mjs'
assert(
typeof value !== 'object' ||
value === null ||
- (value instanceof Lazy && value.transaction === this)
+ (value instanceof LazyValue && value.transaction === this)
)
this.value = value
}
async commit() {
assert(this.value !== undefined)
- if (this.value instanceof Lazy) {
+ if (this.value instanceof LazyValue) {
if (await this.value.commit())
this.dirty = true
this.value = this.value.ptr_len
import Database from './Database.mjs'
-import Lazy from './Lazy.mjs'
+import LazyValue from './LazyValue.mjs'
import LazyArray from './LazyArray.mjs'
import LazyObject from './LazyObject.mjs'
let logjson_to_json = async value => {
- if (value instanceof Lazy) {
+ if (value instanceof LazyValue) {
let new_value
if (value instanceof LazyArray) {
new_value = []
export default {
Database,
- Lazy,
+ LazyValue,
LazyArray,
LazyObject,
logjson_to_json