Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc16fad7

Browse files
committed
update dep and refactor
1 parent634d254 commitc16fad7

File tree

13 files changed

+3809
-1197
lines changed

13 files changed

+3809
-1197
lines changed

‎.vscode/temp.sql‎

Whitespace-only changes.

‎package.json‎

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,29 @@
4747
"react-component"
4848
],
4949
"dependencies": {
50-
"react":"^15.3.1",
51-
"react-dom":"^15.3.1",
52-
"react-redux":"^5.0.3",
53-
"redux":"^3.5.2"
50+
"react":"^16.3.2",
51+
"react-dom":"^16.3.2",
52+
"react-redux":"^5.0.7",
53+
"redux":"^4.0.0"
5454
},
5555
"devDependencies": {
56-
"@types/chai":"^4.0.3",
57-
"@types/mocha":"^2.2.33",
58-
"@types/react":"^15.0.30",
59-
"@types/react-redux":"^5.0.1",
60-
"chai":"^4.1.1",
61-
"cross-env":"^5.0.5",
62-
"glob":"^7.0.6",
63-
"mocha":"^3.2.0",
64-
"rimraf":"^2.5.4",
65-
"source-map-support":"^0.4.2",
66-
"ts-loader":"^2.1.0",
67-
"typescript":"^2.3.4",
68-
"webpack":"^3.5.3",
69-
"webpack-node-externals":"^1.3.3"
56+
"@types/chai":"^4.1.3",
57+
"@types/mocha":"^5.2.0",
58+
"@types/react":"^16.3.13",
59+
"@types/react-redux":"^5.0.19",
60+
"chai":"^4.1.2",
61+
"cross-env":"^5.1.4",
62+
"glob":"^7.1.2",
63+
"mocha":"^5.1.1",
64+
"prettier-tslint":"^0.4.0",
65+
"rimraf":"^2.6.2",
66+
"source-map-support":"^0.5.5",
67+
"ts-loader":"^4.2.0",
68+
"tslint-config-airbnb":"^5.8.0",
69+
"typescript":"^2.8.3",
70+
"webpack":"^4.7.0",
71+
"webpack-cli":"^2.1.3",
72+
"webpack-node-externals":"^1.7.2"
7073
},
7174
"peerDependencies": {
7275
"react":">=15",

‎src/index.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export*from"./utils/actionHelpers"
2-
export*from"./utils/reducerBuilder"
3-
export*from"./utils/storeBuilder"
1+
export*from'./utils/actionHelpers'
2+
export*from'./utils/reducerBuilder'
3+
export*from'./utils/storeBuilder'

‎src/utils/actionHelpers.ts‎

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,43 @@
1-
import"./promiseHelpers"
1+
import'./promiseHelpers'
22
import{Dispatch,Action}from'redux'
33

44
exporttypeNullableDispatch=Dispatch<any>|void
55

6-
exportabstractclassSyncActionimplementsAction{
7-
type:string
6+
exportabstractclassSyncActionimplementsAction<string>{
7+
type:string
88
}
99

1010
exportabstractclassAsyncActionextendsSyncAction{
11-
privateresolve:(value?:Dispatch<any>|PromiseLike<Dispatch<any>>)=>void
12-
privatepromise:Promise<Dispatch<any>>=newPromise<Dispatch<any>>((resolve,reject)=>{
13-
this.resolve=resolve
14-
})
11+
privateresolve:(value?:Dispatch<any>|PromiseLike<Dispatch<any>>)=>void
12+
privatepromise:Promise<Dispatch<any>>=newPromise<Dispatch<any>>(
13+
(resolve,reject)=>{
14+
this.resolve=resolve
15+
},
16+
)
1517

16-
then(onfulfilled?:(value:Dispatch<any>)=>NullableDispatch|PromiseLike<NullableDispatch>,onrejected?:(reason:any)=>void):Promise<NullableDispatch>{
17-
returnthis.promise.then(onfulfilled,onrejected)
18-
}
18+
then(
19+
onfulfilled?:(
20+
value:Dispatch<any>,
21+
)=>NullableDispatch|PromiseLike<NullableDispatch>,
22+
onrejected?:(reason:any)=>void,
23+
):Promise<NullableDispatch>{
24+
returnthis.promise.then(onfulfilled,onrejected)
25+
}
1926

20-
catch(onrejected?:(reason:any)=>NullableDispatch|PromiseLike<NullableDispatch>):Promise<NullableDispatch>{
21-
returnthis.promise.catch(onrejected)
22-
}
27+
catch(
28+
onrejected?:(
29+
reason:any,
30+
)=>NullableDispatch|PromiseLike<NullableDispatch>,
31+
):Promise<NullableDispatch>{
32+
returnthis.promise.catch(onrejected)
33+
}
2334

24-
finally(onfulfilled?:(value?:NullableDispatch,isSuccess?:boolean)=>any|PromiseLike<NullableDispatch>):Promise<NullableDispatch>{
25-
returnthis.promise.finally(onfulfilled)
26-
}
35+
finally(
36+
onfulfilled?:(
37+
value?:NullableDispatch,
38+
isSuccess?:boolean,
39+
)=>any|PromiseLike<NullableDispatch>,
40+
):Promise<NullableDispatch>{
41+
returnthis.promise.finally(onfulfilled)
42+
}
2743
}

‎src/utils/asyncMiddleware.ts‎

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,41 @@
1-
import{Action,MiddlewareAPI,Dispatch}from'redux'
1+
import{Action,Middleware}from'redux'
22
import{SyncAction,AsyncAction}from'./actionHelpers'
33

4-
54
constisSyncAction=(action:Action):action isany=>{
6-
returnactioninstanceofSyncAction
5+
returnactioninstanceofSyncAction
76
}
87

98
constisAsyncAction=(action:Action):action isany=>{
10-
returnactioninstanceofAsyncAction
9+
returnactioninstanceofAsyncAction
1110
}
1211

1312
constmergeObject=(action:any):any=>{
14-
letmerged:any={}
15-
for(varkeyinaction){
16-
if(key!=='constructor'){
17-
merged[key]=(<any>action)[key]
18-
}
13+
constmerged:any={}
14+
for(constkeyinaction){
15+
if(key!=='constructor'){
16+
merged[key]=(<any>action)[key]
1917
}
20-
returnmerged
18+
}
19+
returnmerged
2120
}
2221

23-
exportconstasyncMiddleware=<S>(store:MiddlewareAPI<S>)=>(next:Dispatch<S>):Dispatch<S>=>(action:Action)=>{
24-
if(isSyncAction(action)){
25-
action.type=(<any>action).constructor.name
22+
exportconstasyncMiddleware:Middleware=store=>next=>action=>{
23+
if(isSyncAction(action)){
24+
action.type=action.constructor.name
2625

27-
if(isAsyncAction(action)){
28-
//After original dispatch lifecycle, resolve dispatch in order to handle async operations
29-
setTimeout(()=>{
30-
(<any>action).resolve(store.dispatch)
31-
})
32-
}
26+
if(isAsyncAction(action)){
27+
//After original dispatch lifecycle, resolve dispatch in order to handle async operations
28+
setTimeout(()=>{
29+
action.resolve(store.dispatch)
30+
})
31+
}
3332

34-
//Fix: Actions must be plain objects.
35-
letmerged=mergeObject(action)
33+
//Fix: Actions must be plain objects.
34+
constmerged=mergeObject(action)
3635

37-
//Change state immediately and register async operations
38-
returnnext(merged)
39-
}
36+
//Change state immediately and register async operations
37+
returnnext(merged)
38+
}
4039

41-
returnnext(action)
40+
returnnext(action)
4241
}

‎src/utils/browserPolyfill.ts‎

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,43 @@
11
/**
22
* Hack in support for Function.name for browsers that don't support it.
33
* https://stackoverflow.com/questions/25140723/constructor-name-is-undefined-in-internet-explorer
4-
**/
5-
if(Function.prototype.name===undefined&&Object.defineProperty!==undefined){
6-
Object.defineProperty(Function.prototype,'name',{
7-
get:function(){
8-
varfuncNameRegex=/function\s([^(]{1,})\(/;
9-
varresults=(funcNameRegex).exec((this).toString());
10-
return(results&&results.length>1) ?results[1].trim() :"";
11-
},
12-
set:function(value){}
13-
});
4+
**/
5+
if(
6+
Function.prototype.name===undefined&&
7+
Object.defineProperty!==undefined
8+
){
9+
Object.defineProperty(Function.prototype,'name',{
10+
get(){
11+
constfuncNameRegex=/function\s([^(]{1,})\(/
12+
constresults=funcNameRegex.exec(this.toString())
13+
returnresults&&results.length>1 ?results[1].trim() :''
14+
},
15+
set(value){},
16+
})
1417
}
1518

1619
/*
1720
* Polyfill for Object.assign
1821
* https://github.com/Microsoft/TypeScript/issues/3429#issuecomment-173213973
1922
*/
20-
if(typeofObject.assign!='function'){
21-
Object.assign=function(target:any){
22-
'use strict';
23-
if(target==null){
24-
thrownewTypeError('Cannot convert undefined or null to object');
25-
}
23+
if(typeofObject.assign!=='function'){
24+
Object.assign=function(target:any){
25+
'use strict'
26+
if(target==null){
27+
thrownewTypeError('Cannot convert undefined or null to object')
28+
}
2629

27-
target=Object(target);
28-
for(varindex=1;index<arguments.length;index++){
29-
varsource=arguments[index];
30-
if(source!=null){
31-
for(varkeyinsource){
32-
if(Object.prototype.hasOwnProperty.call(source,key)){
33-
target[key]=source[key];
34-
}
35-
}
36-
}
30+
constobj=Object(target)
31+
for(constkeyinarguments){
32+
constsource=arguments[key]
33+
if(source!=null){
34+
for(constkeyinsource){
35+
if(Object.prototype.hasOwnProperty.call(source,key)){
36+
obj[key]=source[key]
37+
}
3738
}
38-
returntarget;
39-
};
40-
}
39+
}
40+
}
41+
returnobj
42+
}
43+
}

‎src/utils/promiseHelpers.ts‎

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
interfacePromise<T>{
2-
finally<TResult>(onfulfilled?:(value?:T,isSuccess?:boolean)=>TResult|PromiseLike<TResult>):Promise<TResult>
2+
finally<TResult>(
3+
onfulfilled?:(
4+
value?:T,
5+
isSuccess?:boolean,
6+
)=>TResult|PromiseLike<TResult>,
7+
):Promise<TResult>
38
}
49

5-
Promise.prototype['finally']=functionfinallyPolyfill<TResult>(callback:(value?:any,isSuccess?:boolean)=>TResult|PromiseLike<TResult>){
6-
varconstructor=this.constructor
7-
8-
returnthis.then(function(value:any){
9-
returnconstructor.resolve(callback(value,true)).then(function(){
10-
returnvalue
11-
})
12-
},function(reason:any){
13-
returnconstructor.resolve(callback(reason,false)).then(function(){
14-
throwreason
15-
})
16-
})
17-
}
10+
Promise.prototype['finally']=functionfinallyPolyfill<TResult>(
11+
callback:(value?:any,isSuccess?:boolean)=>TResult|PromiseLike<TResult>,
12+
){
13+
return(thisasPromise<TResult>).then(
14+
value=>Promise.resolve(callback(value,true)).then(()=>value),
15+
reason=>
16+
Promise.resolve(callback(reason,false)).then(()=>{
17+
throwreason
18+
}),
19+
)
20+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp