Skip to content

Commit

Permalink
chore(config): update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
falsandtru committed Oct 3, 2016
1 parent aeda29c commit 0f8a298
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 59 deletions.
16 changes: 8 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ GEM
execjs
coffee-script-source (1.10.0)
colorator (1.1.0)
ethon (0.9.0)
ethon (0.9.1)
ffi (>= 1.3.0)
execjs (2.7.0)
faraday (0.9.2)
Expand All @@ -31,7 +31,7 @@ GEM
multi_json (~> 1.0)
net-http-persistent (>= 2.7)
net-http-pipeline
github-pages (94)
github-pages (96)
activesupport (= 4.2.7)
github-pages-health-check (= 1.2.0)
jekyll (= 3.2.1)
Expand All @@ -50,7 +50,7 @@ GEM
liquid (= 3.0.6)
listen (= 3.0.6)
mercenary (~> 0.3)
minima (= 1.0.1)
minima (= 1.2.0)
rouge (= 1.11.1)
terminal-table (~> 1.4)
github-pages-health-check (1.2.0)
Expand Down Expand Up @@ -111,8 +111,8 @@ GEM
rb-inotify (>= 0.9.7)
mercenary (0.3.6)
mini_portile2 (2.1.0)
minima (1.0.1)
minitest (5.9.0)
minima (1.2.0)
minitest (5.9.1)
multi_json (1.12.1)
multipart-post (2.0.0)
net-dns (0.8.0)
Expand All @@ -139,8 +139,8 @@ GEM
sawyer (0.7.0)
addressable (>= 2.3.5, < 2.5)
faraday (~> 0.8, < 0.10)
terminal-table (1.7.0)
unicode-display_width (~> 1.1)
terminal-table (1.7.3)
unicode-display_width (~> 1.1.1)
thread_safe (0.3.5)
travis (1.8.2)
backports
Expand All @@ -155,7 +155,7 @@ GEM
ethon (>= 0.8.0)
tzinfo (1.2.2)
thread_safe (~> 0.1)
unicode-display_width (1.1.0)
unicode-display_width (1.1.1)
websocket (1.2.3)

PLATFORMS
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,35 @@
],
"dependencies": {},
"devDependencies": {
"@types/mocha": "^2.2.31",
"@types/power-assert": "0.0.27",
"@types/mocha": "^2.2.32",
"@types/power-assert": "1.4.29",
"del": "^2.2.2",
"extend": "^3.0.0",
"gulp": "^3.9.1",
"gulp-footer": "^1.0.5",
"gulp-header": "1.8.8",
"gulp-load-plugins": "^1.2.4",
"gulp-load-plugins": "^1.3.0",
"gulp-mocha": "^3.0.1",
"gulp-rename": "^1.2.2",
"gulp-typescript": "^2.13.6",
"gulp-typescript": "^3.0.2",
"gulp-uglify": "^2.0.0",
"gulp-unassert": "^1.0.0",
"json": "^9.0.4",
"karma": "1.2.0",
"karma": "1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-coverage": "^1.1.1",
"karma-coveralls": "^1.1.2",
"karma-espower-preprocessor": "1.1.0",
"karma-firefox-launcher": "^1.0.0",
"karma-mocha": "^1.1.1",
"lodash": "^4.15.0",
"mocha": "^3.0.2",
"npm-check-updates": "^2.8.0",
"karma-mocha": "^1.2.0",
"lodash": "^4.16.2",
"mocha": "^3.1.0",
"npm-check-updates": "^2.8.1",
"power-assert": "^1.4.1",
"run-sequence": "^1.2.2",
"semver": "^5.3.0",
"spica": "0.0.31",
"typescript": "2.1.0-dev.20160903"
"spica": "0.0.33",
"typescript": "2.1.0-dev.20161003"
},
"scripts": {
"test": "gulp server"
Expand Down
4 changes: 2 additions & 2 deletions src/layer/data/schema/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ abstract class EventRecord<K extends string, V extends EventValue> {
date: number,
type: EventType
) {
if (typeof this.id === 'number' && this.id > 0 === false || this.id !== void 0) throw new TypeError(`LocalSocket: EventRecord: Invalid event id: ${this.id}`);
if (typeof this.id === 'number' && <number>this.id > 0 === false || this.id !== void 0) throw new TypeError(`LocalSocket: EventRecord: Invalid event id: ${this.id}`);
this.type = type;
if (typeof this.type !== 'string') throw new TypeError(`LocalSocket: EventRecord: Invalid event type: ${this.type}`);
this.key = key;
Expand Down Expand Up @@ -89,7 +89,7 @@ export class SavedEventRecord<K extends string, V extends EventValue> extends Ev
) {
super(key, value, date, type);
this.EVENT_RECORD;
if (this.id > 0 === false) throw new TypeError(`LocalSocket: SavedEventRecord: Invalid event id: ${this.id}`);
if (<number>this.id > 0 === false) throw new TypeError(`LocalSocket: SavedEventRecord: Invalid event id: ${this.id}`);
void Object.freeze(this);
}
}
Expand Down
49 changes: 27 additions & 22 deletions src/layer/data/store/event.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Supervisor, Observable, sqid, concat } from 'spica';
import { Observable, sqid, concat } from 'spica';
import { listen, Config, IDBTransactionMode, IDBCursorDirection, IDBKeyRange } from '../../infrastructure/indexeddb/api';
import { IdNumber } from '../constraint/types';
import { EventRecordFields, UnsavedEventRecord, SavedEventRecord } from '../schema/event';
Expand Down Expand Up @@ -68,19 +68,17 @@ export abstract class EventStore<K extends string, V extends EventStore.Value> {
}();

// dispatch events
void this.memory.events.exec
.monitor([], ([, sub]): void => {
const event = sub(void 0);
void this.events_.update
.monitor([], (event): void => {
if (event instanceof UnsavedEventRecord) return;
assert(event instanceof SavedEventRecord);
if (event.date <= states.date.get(event.key) && event.id <= states.id.get(event.key)) return;
void this.events.load
.emit([event.key, event.attr, event.type], new EventStore.Event(event.type, event.id, event.key, event.attr, event.date));
});
// update states
void this.memory.events.exec
.monitor([], ([, sub]): void => {
const event = sub(void 0);
void this.events_.update
.monitor([], (event): void => {
void states.update(new EventStore.Event(event.type, event.id || IdNumber(0), event.key, event.attr, event.date));
});
void this.events.load
Expand All @@ -99,21 +97,22 @@ export abstract class EventStore<K extends string, V extends EventStore.Value> {
}
});
}
private readonly memory = new class extends Supervisor<never[] | [K] | [K, string] | [K, string, string], void, UnsavedEventRecord<K, V> | SavedEventRecord<K, V>> { }();
private readonly memory = new Observable<never[] | [K] | [K, string] | [K, string, string], void, UnsavedEventRecord<K, V> | SavedEventRecord<K, V>>();
public readonly events = {
load: new Observable<never[] | [K] | [K, string] | [K, string, EventStore.EventType], EventStore.Event<K>, void>(),
save: new Observable<never[] | [K] | [K, string] | [K, string, EventStore.EventType], EventStore.Event<K>, void>(),
loss: new Observable<never[] | [K] | [K, string] | [K, string, EventStore.EventType], EventStore.Event<K>, void>(),
};
public readonly events_ = {
update: new Observable<never[] | [K] | [K, string], UnsavedEventRecord<K, V> | SavedEventRecord<K, V>, void>(),
access: new Observable<never[] | [K] | [K, string] | [K, string, InternalEventType], InternalEvent<K>, void>()
};
private update(key: K, attr?: string, id?: string): void {
return typeof id === 'string' && typeof attr === 'string'
? void this.memory.cast([key, attr, id], void 0)
? void this.memory.emit([key, attr, id], void 0)
: typeof attr === 'string'
? void this.memory.cast([key, attr], void 0)
: void this.memory.cast([key], void 0);
? void this.memory.emit([key, attr], void 0)
: void this.memory.emit([key], void 0);
}
private readonly syncState = new Map<K, boolean>();
private readonly syncWaits = new Observable<[K], DOMError | null, any>();
Expand Down Expand Up @@ -166,7 +165,9 @@ export abstract class EventStore<K extends string, V extends EventStore.Value> {
assert(this.memory.refs([e.key, e.attr, sqid(e.id)]).length === 0);
assert(this.memory.refs([e.key, e.attr, sqid(e.id + 1)]).length === 0);
void this.memory
.register([e.key, e.attr, sqid(e.id)], () => e);
.on([e.key, e.attr, sqid(e.id)], () => e);
void this.memory
.once([e.key], () => { throw void this.events_.update.emit([e.key, e.attr, sqid(e.id)], e); });
});
void this.syncState.set(key, true);
void this.syncWaits.emit([key], null);
Expand All @@ -186,12 +187,12 @@ export abstract class EventStore<K extends string, V extends EventStore.Value> {
});
}
public keys(): K[] {
return this.memory.cast([], void 0)
return this.memory.reflect([], void 0)
.reduce((keys, e) => keys.length === 0 || keys[keys.length - 1] !== e.key ? concat(keys, [e.key]) : keys, <K[]>[])
.sort();
}
public meta(key: K): MetaData<K> {
const events = this.memory.cast([key], void 0);
const events = this.memory.reflect([key], void 0);
return Object.freeze({
key: key,
id: events.reduce<number>((id, e) =>
Expand All @@ -201,13 +202,13 @@ export abstract class EventStore<K extends string, V extends EventStore.Value> {
});
}
public has(key: K): boolean {
return compose(key, this.memory.cast([key], void 0)).type !== EventStore.EventType.delete;
return compose(key, this.memory.reflect([key], void 0)).type !== EventStore.EventType.delete;
}
public get(key: K): V {
void this.sync([key]);
void this.events_.access
.emit([key], new InternalEvent(InternalEventType.query, IdNumber(0), key, ''));
return compose(key, this.memory.cast([key], void 0))
return compose(key, this.memory.reflect([key], void 0))
.value;
}
public add(event: UnsavedEventRecord<K, V>, tx?: IDBTransaction): void {
Expand All @@ -220,7 +221,7 @@ export abstract class EventStore<K extends string, V extends EventStore.Value> {
switch (event.type) {
case EventStore.EventType.put: {
void this.memory
.terminate([event.key, event.attr, sqid(0)]);
.off([event.key, event.attr, sqid(0)]);
break;
}
case EventStore.EventType.delete:
Expand All @@ -232,12 +233,14 @@ export abstract class EventStore<K extends string, V extends EventStore.Value> {
m.set(<K>key, [<K>key, attr, id])
, new Map())
.forEach(ns =>
void this.memory.terminate(ns));
void this.memory.off(ns));
break;
}
}
const terminate = this.memory
.register([event.key, event.attr, sqid(0), sqid()], () => event);
.on([event.key, event.attr, sqid(0), sqid()], () => event);
void this.memory
.once([event.key, event.attr, sqid(0)], () => { throw void this.events_.update.emit([event.key, event.attr, sqid(0)], event); });
void this.update(event.key, event.attr, sqid(0));
return void new Promise<void>((resolve, reject) => {
void setTimeout(reject, 1000);
Expand All @@ -254,7 +257,9 @@ export abstract class EventStore<K extends string, V extends EventStore.Value> {
void terminate();
const savedEvent = new SavedEventRecord(IdNumber(<number>req.result), event.key, event.value, event.type, event.date);
void this.memory
.register([savedEvent.key, savedEvent.attr, sqid(savedEvent.id)], () => savedEvent);
.on([savedEvent.key, savedEvent.attr, sqid(savedEvent.id)], () => savedEvent);
void this.memory
.once([savedEvent.key, savedEvent.attr, sqid(savedEvent.id)], () => { throw void this.events_.update.emit([savedEvent.key, savedEvent.attr, sqid(savedEvent.id)], savedEvent); });
void this.events.save
.emit([savedEvent.key, savedEvent.attr, savedEvent.type], new EventStore.Event(savedEvent.type, savedEvent.id, savedEvent.key, savedEvent.attr, event.date));
void this.update(savedEvent.key, savedEvent.attr, sqid(savedEvent.id));
Expand Down Expand Up @@ -296,7 +301,7 @@ export abstract class EventStore<K extends string, V extends EventStore.Value> {
void savedEvents.unshift(new SavedEventRecord(event.id, event.key, event.value, event.type, event.date));
}
if (!cursor || (<SavedEventRecord<K, V>>cursor.value).type !== EventStore.EventType.put) {
assert(this.snapshotCycle > 0);
assert(<number>this.snapshotCycle > 0);
if (savedEvents.length === 0) return;
const composedEvent = compose(key, savedEvents);
if (composedEvent instanceof SavedEventRecord) return;
Expand Down Expand Up @@ -333,7 +338,7 @@ export abstract class EventStore<K extends string, V extends EventStore.Value> {
if (!cursor) {
return void removedEvents
.reduce<void>((_, event) =>
void this.memory.terminate([event.key, event.attr, sqid(event.id)])
void this.memory.off([event.key, event.attr, sqid(event.id)])
, void 0);
}
else {
Expand Down
16 changes: 0 additions & 16 deletions test/interface/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,4 @@ describe('Interface: Package', function () {

});

describe('power-assert', function () {
it('assertion self-check', function (done) {
setTimeout(function () {
try {
console.log(assert(!false === !true), assert); // LOG: undefined, function powerAssert() { ... }
}
catch (e) {
done();
return;
}
throw new Error('WARNING!: assert function does not work.');
}, 1);
});

});

});

0 comments on commit 0f8a298

Please sign in to comment.