update
This commit is contained in:
parent
06e7caab2d
commit
b9e21665e2
12
gulpfile.js
12
gulpfile.js
@ -49,6 +49,7 @@ var jasmine = require('gulp-jasmine')
|
||||
var jasmineBrowser = require('gulp-jasmine-browser')
|
||||
var concat = require('gulp-concat')
|
||||
var watch = require('gulp-watch')
|
||||
var ignore = require('gulp-ignore')
|
||||
|
||||
var polyfills = [
|
||||
'./node_modules/gulp-babel/node_modules/babel-core/node_modules/regenerator/runtime.js'
|
||||
@ -95,7 +96,7 @@ gulp.task('build', function () {
|
||||
blacklist: ['regenerator'],
|
||||
experimental: true
|
||||
}))
|
||||
.pipe(sourcemaps.write())
|
||||
.pipe(sourcemaps.write('.'))
|
||||
.pipe(gulp.dest('.'))
|
||||
})
|
||||
|
||||
@ -110,8 +111,9 @@ gulp.task('test', function () {
|
||||
experimental: true
|
||||
}))
|
||||
.pipe(uglify())
|
||||
.pipe(sourcemaps.write())
|
||||
.pipe(sourcemaps.write('.'))
|
||||
.pipe(gulp.dest('build'))
|
||||
.pipe(ignore.include('*.js'))
|
||||
.pipe(jasmine({
|
||||
verbose: true,
|
||||
includeStuckTrace: true
|
||||
@ -125,9 +127,9 @@ gulp.task('build_jasmine_browser', function () {
|
||||
.pipe(babel({
|
||||
loose: 'all',
|
||||
modules: 'ignore',
|
||||
optional: ['es7.asyncFunctions'],
|
||||
// blacklist: "regenerator",
|
||||
experimental: true
|
||||
// optional: ['es7.asyncFunctions'],
|
||||
blacklist: "regenerator",
|
||||
//experimental: true
|
||||
}))
|
||||
.pipe(sourcemaps.write())
|
||||
.pipe(gulp.dest('build'))
|
||||
|
@ -5,7 +5,7 @@
|
||||
This is just a compilation of functions that help to test this library!
|
||||
***/
|
||||
|
||||
function wait(t = 0) {//eslint-disable-line
|
||||
function wait(t = 10) {//eslint-disable-line
|
||||
var def = Promise.defer()
|
||||
setTimeout(function () {
|
||||
def.resolve()
|
||||
@ -90,6 +90,8 @@ async function compareAllUsers(users){//eslint-disable-line
|
||||
await users[0].connector.flushAll()
|
||||
await garbageCollectAllUsers(users)
|
||||
await wait(200)
|
||||
await garbageCollectAllUsers(users)
|
||||
await wait(200)
|
||||
for (var uid = 0; uid < users.length; uid++) {
|
||||
var u = users[uid]
|
||||
// compare deleted ops against deleteStore
|
||||
|
@ -209,12 +209,16 @@ class AbstractOperationStore { // eslint-disable-line no-unused-vars
|
||||
state.clock++
|
||||
yield* this.checkDeleteStoreForState(state)
|
||||
yield* this.setState(state)
|
||||
var isDeleted = yield* this.store.ds.isDeleted(op.id)
|
||||
|
||||
yield* Struct[op.struct].execute.call(this, op)
|
||||
yield* this.addOperation(op)
|
||||
yield* this.store.operationAdded(this, op)
|
||||
if (op.deleted === true) {
|
||||
this.ds.delete(op.id)
|
||||
|
||||
if (isDeleted) {
|
||||
yield* Struct["Delete"].execute.call(this, {target: op.id})
|
||||
}
|
||||
|
||||
// find next operation to execute
|
||||
op = this.store.waitingOperations.find([op.id[0], state.clock])
|
||||
if (op != null) {
|
||||
|
@ -28,7 +28,7 @@ var Struct = {
|
||||
return [] // [op.target]
|
||||
},
|
||||
execute: function * (op) {
|
||||
console.log('Delete', op, console.trace())
|
||||
// console.log('Delete', op, console.trace())
|
||||
var target = yield* this.getOperation(op.target)
|
||||
if (target != null && !target.deleted) {
|
||||
target.deleted = true
|
||||
@ -50,13 +50,11 @@ var Struct = {
|
||||
yield* t._changed(this, copyObject(op))
|
||||
}
|
||||
}
|
||||
if (target == null || !target.deleted) {
|
||||
this.ds.delete(op.target)
|
||||
var state = yield* this.getState(op.target[0])
|
||||
if (state === op.target[1]) {
|
||||
yield* this.checkDeleteStoreForState(state)
|
||||
yield* this.setState(state)
|
||||
}
|
||||
this.ds.delete(op.target)
|
||||
var state = yield* this.getState(op.target[0])
|
||||
if (state.clock === op.target[1]) {
|
||||
yield* this.checkDeleteStoreForState(state)
|
||||
yield* this.setState(state)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -8,10 +8,10 @@ describe('Array Type', function () {
|
||||
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000
|
||||
beforeEach(async function (done) {
|
||||
await createUsers(this, 2)
|
||||
await createUsers(this, 3)
|
||||
y1 = (yconfig1 = this.users[0]).root
|
||||
y2 = (yconfig2 = this.users[1]).root
|
||||
// y3 = (yconfig3 = this.users[2]).root
|
||||
y3 = (yconfig3 = this.users[2]).root
|
||||
flushAll = this.users[0].connector.flushAll
|
||||
done()
|
||||
})
|
||||
@ -102,8 +102,11 @@ describe('Array Type', function () {
|
||||
l2 = await y2.get('Array')
|
||||
l1.insert(0, ['x', 'y'])
|
||||
l1.delete(0, 2)
|
||||
await wait(500)
|
||||
await flushAll()
|
||||
await wait(500)
|
||||
expect(l1.toArray()).toEqual(l2.toArray())
|
||||
await compareAllUsers(this.users)
|
||||
done()
|
||||
})
|
||||
it('Basic insert. Then delete the whole array', async function (done) {
|
||||
|
2
src/y.js
2
src/y.js
@ -15,7 +15,7 @@ class YConfig { // eslint-disable-line no-unused-vars
|
||||
this.db = new Y[opts.db.name](this, opts.db)
|
||||
this.connector = new Y[opts.connector.name](this, opts.connector)
|
||||
var yconfig = this
|
||||
this.db.requestTransaction(function *() {
|
||||
this.db.requestTransaction(function * requestTransaction () {
|
||||
// create initial Map type
|
||||
var model = {
|
||||
id: ['_', 0],
|
||||
|
Loading…
x
Reference in New Issue
Block a user