-
Notifications
You must be signed in to change notification settings - Fork 1
/
history.js
62 lines (46 loc) · 1.47 KB
/
history.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* history.js: History object providing observability into workers interactions.
*
* (C) 2012 Crosstalk Systems Inc.
*/
var eventIsAuthorized = require( './eventIsAuthorized' );
var history = function history () {
var _all = [];
var _in = [];
var _out = [];
var inPush = function inPush ( message, params, scope, emmittedScope, type,
workerReference ) {
var event = {};
message ? event.message = message : null;
params ? event.params = params : null;
scope ? event.scope = scope : null;
emmittedScope ? event.emmittedScope = emmittedScope : null;
type ? event.type = type : null;
workerReference ? event.workerReference = workerReference : null;
event.authorized = eventIsAuthorized( scope, emmittedScope );
event.in = true;
_all.push( event );
_in.push( event );
}; // inPush
var outPush = function outPush ( message, params, scope, callback, type,
workerReference ) {
var event = {};
message ? event.message = message : null;
params ? event.params = params : null;
scope ? event.scope = scope : null;
callback ? event.callback = callback : null;
type ? event.type = type : null;
workerReference ? event.workerReference = workerReference : null;
event.out = true;
_all.push( event );
_out.push( event );
}; // outPush
return {
_all : _all,
_in : _in,
_out : _out,
in : inPush,
out : outPush
}; // return
}; // history
module.exports = history;