1 |
|
2 |
|
3 | module.exports = function onto(tag, arg, as){
|
4 | if(!tag){ return {to: onto} }
|
5 | var tag = (this.tag || (this.tag = {}))[tag] ||
|
6 | (this.tag[tag] = {tag: tag, to: onto._ = {
|
7 | next: function(){}
|
8 | }});
|
9 | if(arg instanceof Function){
|
10 | var be = {
|
11 | off: onto.off ||
|
12 | (onto.off = function(){
|
13 | if(this.next === onto._.next){ return !0 }
|
14 | if(this === this.the.last){
|
15 | this.the.last = this.back;
|
16 | }
|
17 | this.to.back = this.back;
|
18 | this.next = onto._.next;
|
19 | this.back.to = this.to;
|
20 | }),
|
21 | to: onto._,
|
22 | next: arg,
|
23 | the: tag,
|
24 | on: this,
|
25 | as: as,
|
26 | };
|
27 | (be.back = tag.last || tag).to = be;
|
28 | return tag.last = be;
|
29 | }
|
30 | (tag = tag.to).next(arg);
|
31 | return tag;
|
32 | };
|
33 | |
\ | No newline at end of file |