Skip to content

Commit

Permalink
Merge pull request #9 from yama-dev/v0.5.0
Browse files Browse the repository at this point in the history
V0.5.0
  • Loading branch information
yama-dev authored Jul 5, 2022
2 parents 9355a50 + 358fc65 commit e34d5dc
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 39 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Get multi data library.

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

- 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)
- 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)

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

Expand Down Expand Up @@ -90,6 +90,9 @@ import MULTI_DATA_MODULE from 'js-multi-data-module';
},
Complete: function(data, list){
console.log(data, list);
},
Fail: function(err){
console.log(err);
}
}
});
Expand Down
18 changes: 2 additions & 16 deletions dist/js-multi-data-module.js

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ <h3>Advanced Use</h3>
animation: motionChange 0.7s cubic-bezier(0.215, 0.61, 0.355, 1) 0.2s 1 forwards;
}
</style>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14"></script>
<script>
var app = new Vue({
el: '#app',
Expand Down Expand Up @@ -328,7 +328,10 @@ <h3>Advanced Use</h3>
setTimeout(function(){
_that.flgLoading = false;
},1000)
}
},
Fail: function(err){
console.log(err);
},
}
});
},
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "js-multi-data-module",
"version": "0.4.11",
"version": "0.5.0",
"description": "Get multi data library.",
"keywords": [
"multi-data",
Expand Down Expand Up @@ -39,9 +39,7 @@
"webpack": "^4.28.4",
"webpack-cli": "^3.2.1"
},
"dependencies": {
"es6-promise": "^4.2.5"
},
"dependencies": {},
"eslintConfig": {
"env": {
"browser": true,
Expand Down Expand Up @@ -78,5 +76,8 @@
"no-console": "warn",
"no-unused-vars": "warn"
}
},
"volta": {
"node": "12.22.12"
}
}
26 changes: 16 additions & 10 deletions src/js-multi-data-module.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/*eslint no-console: "off"*/

import Promise from 'es6-promise';

export default class MULTI_DATA_MODULE {

constructor(options={}){
Expand Down Expand Up @@ -34,15 +32,16 @@ export default class MULTI_DATA_MODULE {

// Data obj.
this.DataFix = [];
this.DataList = {};
this.DataList = [];

// Set callback functions.
if(!options.on){
options.on = {};
}
this.On = {
Update : options.on.Update||'',
Complete : options.on.Complete||''
Complete : options.on.Complete||'',
Fail : options.on.Fail||''
};

// For Jsonp data.
Expand Down Expand Up @@ -84,7 +83,7 @@ export default class MULTI_DATA_MODULE {
window.callback = (response)=>{
resolve(response);
};
setTimeout(()=>{ reject('error'); }, this.Config.fetch_timeout);
setTimeout(()=>{ reject('error: timeout'); }, this.Config.fetch_timeout);

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

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

setTimeout(()=>{ reject('error'); }, this.Config.fetch_timeout);
setTimeout(()=>{ reject('error: timeout'); }, this.Config.fetch_timeout);

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

this.DataFix = this.DataFix.concat(['']);
this.DataList[count] = [];
Expand Down Expand Up @@ -301,7 +300,7 @@ export default class MULTI_DATA_MODULE {
xhr.responseType = 'document';
xhr.send(null);

setTimeout(()=>{ reject('error'); }, this.Config.fetch_timeout);
setTimeout(()=>{ reject('error: timeout'); }, this.Config.fetch_timeout);
});

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

this.DataFix = this.DataFix.concat(['']);
this.DataList[count] = [];
Expand Down Expand Up @@ -419,4 +418,11 @@ export default class MULTI_DATA_MODULE {
}
}

OnFail(e={}){
// Callback function.
if(this.On.Fail && typeof(this.On.Fail) === 'function'){
this.On.Fail(e);
}
}

}
7 changes: 1 addition & 6 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
const pkg = require('./package.json');

const comment = `JS MULTI_DATA_MODULE (JavaScript Library)
${pkg.name}
Version ${pkg.version}
Repository ${pkg.repository.url}
Copyright ${pkg.author}
Licensed ${pkg.license}`;
const comment = `@${pkg.author}/${pkg.name} version:${pkg.version} repository:${pkg.repository.url} copyright:${pkg.author} licensed:${pkg.license}`;

const env = process.env.NODE_ENV;

Expand Down

0 comments on commit e34d5dc

Please sign in to comment.