Commit 35e821c 1 parent 7b7fe11 commit 35e821c Copy full SHA for 35e821c
File tree 2 files changed +33
-3
lines changed
2 files changed +33
-3
lines changed Original file line number Diff line number Diff line change 35
35
}
36
36
37
37
/**
38
- * @return {Energy }
38
+ * @return {Energy } emitter instance
39
39
*/
40
40
function energy ( o ) {
41
41
return o instanceof Energy ? o [ init ] ( ) : new Energy ( o ) ;
42
- }
42
+ }
43
+
44
+ /**
45
+ * @this {Function} wrapper that constructs the source instance
46
+ * @param {Object|Function } target to convert into emitter
47
+ * @return {Object|Function } target converted into emitter
48
+ */
49
+ energy [ 'into' ] = function ( target ) {
50
+ return defaults ( target , this . call ( ) ) ;
51
+ } ;
52
+
53
+ /**
54
+ * @this {Energy|Object|Function} source emitter
55
+ * @param {Object|Function } target to convert into emitter
56
+ * @return {Object|Function } target converted into emitter
57
+ */
58
+ emitter [ 'into' ] = function ( target ) {
59
+ return defaults ( target , this ) ;
60
+ } ;
43
61
44
62
/**
45
63
* @param {{length:number} } fns
Original file line number Diff line number Diff line change 11
11
function yes ( ) { return true ; }
12
12
13
13
aok ( 'instance' , emitter instanceof energy ) ;
14
- aok ( 'listeners' , typeof emitter . listeners ( key ) . length == 'number' ) ;
14
+ aok ( 'listeners' , typeof emitter . listeners ( key ) . length == 'number' ) ;
15
+
16
+ aok ( 'into' , function ( ) {
17
+ function wannabe ( ) {
18
+ wannabe . emit ( 'called' ) ;
19
+ }
20
+
21
+ var bool = wannabe === energy . into ( wannabe ) && typeof wannabe . emit == 'function' ;
22
+ bool && wannabe . once ( 'called' , function ( ) {
23
+ bool = this === wannabe ;
24
+ } ) && wannabe ( ) ;
25
+ return bool ;
26
+ } ) ;
15
27
16
28
( function ( id ) {
17
29
var bool = true , gone = indexOf ? function ( what ) {
You can’t perform that action at this time.
0 commit comments