Skip to content

Commit e34d5dc

Browse files
authored
Merge pull request #9 from yama-dev/v0.5.0
V0.5.0
2 parents 9355a50 + 358fc65 commit e34d5dc

File tree

6 files changed

+33
-39
lines changed

6 files changed

+33
-39
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Get multi data library.
1616

1717
- npm -> [https://www.npmjs.com/package/js-multi-data-module](https://www.npmjs.com/package/js-multi-data-module)
1818

19-
- Standalone(CDN) -> [https://cdn.jsdelivr.net/gh/yama-dev/js-multi-data-module@v0.4.11/dist/js-multi-data-module.js](https://cdn.jsdelivr.net/gh/yama-dev/js-multi-data-module@v0.4.11/dist/js-multi-data-module.js)
19+
- Standalone(CDN) -> [https://cdn.jsdelivr.net/gh/yama-dev/js-multi-data-module@v0.5.0/dist/js-multi-data-module.js](https://cdn.jsdelivr.net/gh/yama-dev/js-multi-data-module@v0.5.0/dist/js-multi-data-module.js)
2020

2121
- Zip -> [yama-dev/js-multi-data-module](https://github.com/yama-dev/js-multi-data-module/releases/latest)
2222

@@ -90,6 +90,9 @@ import MULTI_DATA_MODULE from 'js-multi-data-module';
9090
},
9191
Complete: function(data, list){
9292
console.log(data, list);
93+
},
94+
Fail: function(err){
95+
console.log(err);
9396
}
9497
}
9598
});

dist/js-multi-data-module.js

Lines changed: 2 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/index.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ <h3>Advanced Use</h3>
243243
animation: motionChange 0.7s cubic-bezier(0.215, 0.61, 0.355, 1) 0.2s 1 forwards;
244244
}
245245
</style>
246-
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
246+
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14"></script>
247247
<script>
248248
var app = new Vue({
249249
el: '#app',
@@ -328,7 +328,10 @@ <h3>Advanced Use</h3>
328328
setTimeout(function(){
329329
_that.flgLoading = false;
330330
},1000)
331-
}
331+
},
332+
Fail: function(err){
333+
console.log(err);
334+
},
332335
}
333336
});
334337
},

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "js-multi-data-module",
3-
"version": "0.4.11",
3+
"version": "0.5.0",
44
"description": "Get multi data library.",
55
"keywords": [
66
"multi-data",
@@ -39,9 +39,7 @@
3939
"webpack": "^4.28.4",
4040
"webpack-cli": "^3.2.1"
4141
},
42-
"dependencies": {
43-
"es6-promise": "^4.2.5"
44-
},
42+
"dependencies": {},
4543
"eslintConfig": {
4644
"env": {
4745
"browser": true,
@@ -78,5 +76,8 @@
7876
"no-console": "warn",
7977
"no-unused-vars": "warn"
8078
}
79+
},
80+
"volta": {
81+
"node": "12.22.12"
8182
}
8283
}

src/js-multi-data-module.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/*eslint no-console: "off"*/
22

3-
import Promise from 'es6-promise';
4-
53
export default class MULTI_DATA_MODULE {
64

75
constructor(options={}){
@@ -34,15 +32,16 @@ export default class MULTI_DATA_MODULE {
3432

3533
// Data obj.
3634
this.DataFix = [];
37-
this.DataList = {};
35+
this.DataList = [];
3836

3937
// Set callback functions.
4038
if(!options.on){
4139
options.on = {};
4240
}
4341
this.On = {
4442
Update : options.on.Update||'',
45-
Complete : options.on.Complete||''
43+
Complete : options.on.Complete||'',
44+
Fail : options.on.Fail||''
4645
};
4746

4847
// For Jsonp data.
@@ -84,7 +83,7 @@ export default class MULTI_DATA_MODULE {
8483
window.callback = (response)=>{
8584
resolve(response);
8685
};
87-
setTimeout(()=>{ reject('error'); }, this.Config.fetch_timeout);
86+
setTimeout(()=>{ reject('error: timeout'); }, this.Config.fetch_timeout);
8887

8988
} else {
9089
reject('error:not found data.');
@@ -128,7 +127,7 @@ export default class MULTI_DATA_MODULE {
128127
})
129128
.catch((err)=>{
130129
// Error.
131-
console.log('%c'+err,'color: red');
130+
this.OnFail({message: err, data: this.DataList[count]});
132131

133132
this.DataFix = this.DataFix.concat(['']);
134133
this.DataList[count] = [];
@@ -181,7 +180,7 @@ export default class MULTI_DATA_MODULE {
181180
xhr.open('GET', _url, true);
182181
xhr.send(null);
183182

184-
setTimeout(()=>{ reject('error'); }, this.Config.fetch_timeout);
183+
setTimeout(()=>{ reject('error: timeout'); }, this.Config.fetch_timeout);
185184

186185
} else {
187186
reject('error:not found data.');
@@ -225,7 +224,7 @@ export default class MULTI_DATA_MODULE {
225224
})
226225
.catch((err)=>{
227226
// Error.
228-
console.log('%c'+err,'color: red');
227+
this.OnFail({message: err, data: this.DataList[count]});
229228

230229
this.DataFix = this.DataFix.concat(['']);
231230
this.DataList[count] = [];
@@ -301,7 +300,7 @@ export default class MULTI_DATA_MODULE {
301300
xhr.responseType = 'document';
302301
xhr.send(null);
303302

304-
setTimeout(()=>{ reject('error'); }, this.Config.fetch_timeout);
303+
setTimeout(()=>{ reject('error: timeout'); }, this.Config.fetch_timeout);
305304
});
306305

307306
promise
@@ -335,7 +334,7 @@ export default class MULTI_DATA_MODULE {
335334
})
336335
.catch((err)=>{
337336
// Error.
338-
console.log('%c'+err,'color: red');
337+
this.OnFail({message: err, data: this.DataList[count]});
339338

340339
this.DataFix = this.DataFix.concat(['']);
341340
this.DataList[count] = [];
@@ -419,4 +418,11 @@ export default class MULTI_DATA_MODULE {
419418
}
420419
}
421420

421+
OnFail(e={}){
422+
// Callback function.
423+
if(this.On.Fail && typeof(this.On.Fail) === 'function'){
424+
this.On.Fail(e);
425+
}
426+
}
427+
422428
}

webpack.config.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
const pkg = require('./package.json');
22

3-
const comment = `JS MULTI_DATA_MODULE (JavaScript Library)
4-
${pkg.name}
5-
Version ${pkg.version}
6-
Repository ${pkg.repository.url}
7-
Copyright ${pkg.author}
8-
Licensed ${pkg.license}`;
3+
const comment = `@${pkg.author}/${pkg.name} version:${pkg.version} repository:${pkg.repository.url} copyright:${pkg.author} licensed:${pkg.license}`;
94

105
const env = process.env.NODE_ENV;
116

0 commit comments

Comments
 (0)