This repository was archived by the owner on Jun 5, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +22
-18
lines changed Expand file tree Collapse file tree 2 files changed +22
-18
lines changed Original file line number Diff line number Diff line change 69
69
</ details >
70
70
</ dl >
71
71
</ template >
72
- < script src ='js/script.js '> </ script >
72
+ < script src ='js/script.js?_=1526892615177 '> </ script >
73
73
</ body >
74
74
</ html >
Original file line number Diff line number Diff line change 37
37
get ( path ) {
38
38
path = `${ this . owner } /${ this . repo } /${ path } ` ;
39
39
let data = getCache ( path ) ;
40
- if ( data ) return Promise . resolve ( data ) ;
40
+ if ( data ) return Promise . resolve ( data ) . then ( dispatch ) ;
41
41
42
42
return fetch ( `${ api } /${ path } ` ) . then (
43
43
( resp ) => this . normalize ( resp )
46
46
new CustomEvent ( 'gohub-catch' , { detail : data } )
47
47
) ;
48
48
return data ;
49
- } ) ;
49
+ } ) . then ( dispatch ) ;
50
50
}
51
51
52
52
normalize ( resp ) {
67
67
slice ( 1 ) . toLowerCase ( ) ,
68
68
text = Base64 . decode ( json . content ) ,
69
69
content = ext === 'json' &&
70
- JSON . parse ( text ) || text ,
71
- data = storeCache (
72
- url , {
73
- owner, repo,
74
- name : json . name ,
75
- url : json . html_url ,
76
- sha : json . sha ,
77
- path,
78
- ext,
79
- content,
80
- }
81
- ) ;
82
- document . dispatchEvent (
83
- new CustomEvent ( 'gohub-got' , { detail : data } )
70
+ JSON . parse ( text ) || text ;
71
+
72
+ return storeCache (
73
+ url , {
74
+ owner, repo,
75
+ name : json . name ,
76
+ url : json . html_url ,
77
+ sha : json . sha ,
78
+ path,
79
+ ext,
80
+ content,
81
+ }
84
82
) ;
85
- return data ;
86
83
} ) ;
87
84
}
88
85
}
89
86
87
+ function dispatch ( data ) {
88
+ document . dispatchEvent (
89
+ new CustomEvent ( 'gohub-got' , { detail : data } )
90
+ ) ;
91
+ return data ;
92
+ }
93
+
90
94
global . gohub = function ( owner , repo ) {
91
95
if ( ! owner ) return gohub . prototype ;
92
96
return new gohub ( owner , repo ) ;
You can’t perform that action at this time.
0 commit comments