flow.js
713 Bytes
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
(function(factory){
if(typeof define != "undefined"){
define([], factory);
}else if(typeof module != "undefined"){
module.exports = factory();
}else{
dclAdvicesFlow = factory();
}
})(function(){
"use strict";
var flowStack = [], flowCount = {};
return {
advice: function(name){
return {
before: function(){
flowStack.push(name);
if(flowCount[name]){
++flowCount[name];
}else{
flowCount[name] = 1;
}
},
after: function(){
--flowCount[name];
flowStack.pop();
}
};
},
inFlowOf: function(name){
return flowCount[name];
},
getStack: function(){
return flowStack;
},
getCount: function(){
return flowCount;
}
};
});