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

Commit15cf992

Browse files
committed
Remove method chaining and change delay() to static
1 parent5394724 commit15cf992

File tree

8 files changed

+95
-96
lines changed

8 files changed

+95
-96
lines changed

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name":"algorithm-visualizer",
3-
"version":"2.3.1",
3+
"version":"2.3.2",
44
"description":"Visualization Library for JavaScript",
55
"keywords": [
66
"algorithm",

‎src/Array1DTracer.ts‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
import{Array2DTracer,ChartTracer}from'./';
22

33
classArray1DTracerextendsArray2DTracer{
4-
set(array1d?:any[]): this{
5-
returnthis.command('set',arguments);
4+
set(array1d?:any[]){
5+
this.command('set',arguments);
66
}
77

8-
patch(x:number,v?:any): this{
9-
returnthis.command('patch',arguments);
8+
patch(x:number,v?:any){
9+
this.command('patch',arguments);
1010
}
1111

12-
depatch(x:number): this{
13-
returnthis.command('depatch',arguments);
12+
depatch(x:number){
13+
this.command('depatch',arguments);
1414
}
1515

16-
select(sx:number,ex?:number): this{
17-
returnthis.command('select',arguments);
16+
select(sx:number,ex?:number){
17+
this.command('select',arguments);
1818
}
1919

20-
deselect(sx:number,ex?:number): this{
21-
returnthis.command('deselect',arguments);
20+
deselect(sx:number,ex?:number){
21+
this.command('deselect',arguments);
2222
}
2323

24-
chart(chartTracer:ChartTracer): this{
25-
returnthis.command('chart',arguments);
24+
chart(chartTracer:ChartTracer){
25+
this.command('chart',arguments);
2626
}
2727
}
2828

‎src/Array2DTracer.ts‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
import{Tracer}from'./';
22

33
classArray2DTracerextendsTracer{
4-
set(array2d?:any[][]): this{
5-
returnthis.command('set',arguments);
4+
set(array2d?:any[][]){
5+
this.command('set',arguments);
66
}
77

8-
patch(x:number,y:number,v?:any): this{
9-
returnthis.command('patch',arguments);
8+
patch(x:number,y:number,v?:any){
9+
this.command('patch',arguments);
1010
}
1111

12-
depatch(x:number,y:number): this{
13-
returnthis.command('depatch',arguments);
12+
depatch(x:number,y:number){
13+
this.command('depatch',arguments);
1414
}
1515

16-
select(sx:number,sy:number,ex?:number,ey?:number): this{
17-
returnthis.command('select',arguments);
16+
select(sx:number,sy:number,ex?:number,ey?:number){
17+
this.command('select',arguments);
1818
}
1919

20-
selectRow(x:number,sy:number,ey:number): this{
21-
returnthis.command('selectRow',arguments);
20+
selectRow(x:number,sy:number,ey:number){
21+
this.command('selectRow',arguments);
2222
}
2323

24-
selectCol(y:number,sx:number,ex:number): this{
25-
returnthis.command('selectCol',arguments);
24+
selectCol(y:number,sx:number,ex:number){
25+
this.command('selectCol',arguments);
2626
}
2727

28-
deselect(sx:number,sy:number,ex?:number,ey?:number): this{
29-
returnthis.command('deselect',arguments);
28+
deselect(sx:number,sy:number,ex?:number,ey?:number){
29+
this.command('deselect',arguments);
3030
}
3131

32-
deselectRow(x:number,sy:number,ey:number): this{
33-
returnthis.command('deselectRow',arguments);
32+
deselectRow(x:number,sy:number,ey:number){
33+
this.command('deselectRow',arguments);
3434
}
3535

36-
deselectCol(y:number,sx:number,ex:number): this{
37-
returnthis.command('deselectCol',arguments);
36+
deselectCol(y:number,sx:number,ex:number){
37+
this.command('deselectCol',arguments);
3838
}
3939
}
4040

‎src/Commander.ts‎

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Commander {
1414
privatestaticobjectCount=0;
1515
publicstaticcommands:Command[]=[];
1616

17-
staticcommand(key:string|null,method:string,iArguments:IArguments):Commander{
17+
staticcommand(key:string|null,method:string,iArguments:IArguments){
1818
constargs=Array.from(iArguments);
1919
this.commands.push({
2020
key,
@@ -23,38 +23,24 @@ class Commander {
2323
});
2424
if(this.commands.length>MAX_COMMANDS)thrownewError('Too Many Commands');
2525
if(this.objectCount>MAX_OBJECTS)thrownewError('Too Many Objects');
26-
return(<any>this);
27-
}
28-
29-
staticsetRoot(child:Commander):Commander{
30-
returnthis.command(null,'setRoot',arguments);
31-
}
32-
33-
staticdelay(lineNumber?:Number):Commander{
34-
returnthis.command(null,'delay',arguments);
3526
}
3627

3728
privatereadonlykey:string;
3829

3930
constructor(iArguments:IArguments){
31+
Commander.objectCount++;
4032
constclassName=(<any>this).constructor.name;
4133
this.key=Commander.keyRandomizer.create();
4234
this.command(className,iArguments);
4335
}
4436

4537
destroy(){
4638
Commander.objectCount--;
47-
returnthis.command('destroy',arguments);
39+
this.command('destroy',arguments);
4840
}
4941

50-
command(method:string,iArguments:IArguments): this{
42+
command(method:string,iArguments:IArguments){
5143
Commander.command(this.key,method,iArguments);
52-
returnthis;
53-
}
54-
55-
delay(lineNumber?:Number): this{
56-
Commander.delay(lineNumber);
57-
returnthis;
5844
}
5945

6046
toJSON(){

‎src/GraphTracer.ts‎

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,77 @@
11
import{LogTracer,Tracer}from'./';
22

33
classGraphTracerextendsTracer{
4-
set(array2d?:any[][]): this{
5-
returnthis.command('set',arguments);
4+
set(array2d?:any[][]){
5+
this.command('set',arguments);
66
}
77

8-
directed(isDirected?:boolean): this{
9-
returnthis.command('directed',arguments);
8+
directed(isDirected?:boolean){
9+
this.command('directed',arguments);
10+
returnthis;
1011
}
1112

12-
weighted(isWeighted?:boolean): this{
13-
returnthis.command('weighted',arguments);
13+
weighted(isWeighted?:boolean){
14+
this.command('weighted',arguments);
15+
returnthis;
1416
}
1517

16-
addNode(id:any,weight?:any,x?:number,y?:number,visitedCount?:number,selectedCount?:number): this{
17-
returnthis.command('addNode',arguments);
18+
layoutCircle(){
19+
this.command('layoutCircle',arguments);
20+
returnthis;
1821
}
1922

20-
updateNode(id:any,weight?:any,x?:number,y?:number,visitedCount?:number,selectedCount?:number): this{
21-
returnthis.command('updateNode',arguments);
23+
layoutTree(root?:any,sorted?:boolean){
24+
this.command('layoutTree',arguments);
25+
returnthis;
2226
}
2327

24-
removeNode(id:any): this{
25-
returnthis.command('removeNode',arguments);
28+
layoutRandom(){
29+
this.command('layoutRandom',arguments);
30+
returnthis;
2631
}
2732

28-
addEdge(source:any,target:any,weight?:any,visitedCount?:number,selectedCount?:number): this{
29-
returnthis.command('addEdge',arguments);
33+
addNode(id:any,weight?:any,x?:number,y?:number,visitedCount?:number,selectedCount?:number){
34+
this.command('addNode',arguments);
3035
}
3136

32-
updateEdge(source:any,target:any,weight?:any,visitedCount?:number,selectedCount?:number): this{
33-
returnthis.command('updateEdge',arguments);
37+
updateNode(id:any,weight?:any,x?:number,y?:number,visitedCount?:number,selectedCount?:number){
38+
this.command('updateNode',arguments);
3439
}
3540

36-
removeEdge(source:any,target:any): this{
37-
returnthis.command('removeEdge',arguments);
41+
removeNode(id:any){
42+
this.command('removeNode',arguments);
3843
}
3944

40-
layoutCircle(){
41-
returnthis.command('layoutCircle',arguments);
45+
addEdge(source:any,target:any,weight?:any,visitedCount?:number,selectedCount?:number){
46+
this.command('addEdge',arguments);
4247
}
4348

44-
layoutTree(root?:any,sorted?:boolean){
45-
returnthis.command('layoutTree',arguments);
49+
updateEdge(source:any,target:any,weight?:any,visitedCount?:number,selectedCount?:number){
50+
this.command('updateEdge',arguments);
4651
}
4752

48-
layoutRandom(){
49-
returnthis.command('layoutRandom',arguments);
53+
removeEdge(source:any,target:any){
54+
this.command('removeEdge',arguments);
5055
}
5156

5257
visit(target:any,source?:any,weight?:any){
53-
returnthis.command('visit',arguments);
58+
this.command('visit',arguments);
5459
}
5560

5661
leave(target:any,source?:any,weight?:any){
57-
returnthis.command('leave',arguments);
62+
this.command('leave',arguments);
5863
}
5964

6065
select(target:any,source?:any){
61-
returnthis.command('select',arguments);
66+
this.command('select',arguments);
6267
}
6368

6469
deselect(target:any,source?:any){
65-
returnthis.command('deselect',arguments);
70+
this.command('deselect',arguments);
6671
}
6772

6873
log(logTracer:LogTracer){
69-
returnthis.command('log',arguments);
74+
this.command('log',arguments);
7075
}
7176
}
7277

‎src/Layout.ts‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
import{Commander}from'./';
22

33
classLayoutextendsCommander{
4+
staticsetRoot(child:Commander){
5+
this.command(null,'setRoot',arguments);
6+
}
7+
48
constructor(children:[Commander]){
59
super(arguments);
610
}
711

8-
add(child:Commander,index?:Number): this{
9-
returnthis.command('add',arguments);
12+
add(child:Commander,index?:Number){
13+
this.command('add',arguments);
1014
}
1115

12-
remove(child:Commander): this{
13-
returnthis.command('remove',arguments);
16+
remove(child:Commander){
17+
this.command('remove',arguments);
1418
}
1519

16-
removeAll(): this{
17-
returnthis.command('removeAll',arguments);
20+
removeAll(){
21+
this.command('removeAll',arguments);
1822
}
1923
}
2024

‎src/LogTracer.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import{Tracer}from'./';
22

33
classLogTracerextendsTracer{
4-
set(log?:string): this{
5-
returnthis.command('set',arguments);
4+
set(log?:string){
5+
this.command('set',arguments);
66
}
77

8-
print(message:any): this{
9-
returnthis.command('print',arguments);
8+
print(message:any){
9+
this.command('print',arguments);
1010
}
1111

12-
println(message:any): this{
13-
returnthis.command('println',arguments);
12+
println(message:any){
13+
this.command('println',arguments);
1414
}
1515

16-
printf(format:string, ...args:any[]): this{
17-
returnthis.command('printf',arguments);
16+
printf(format:string, ...args:any[]){
17+
this.command('printf',arguments);
1818
}
1919
}
2020

‎src/Tracer.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import{Commander}from'./';
22

33
classTracerextendsCommander{
4+
staticdelay(lineNumber?:Number){
5+
this.command(null,'delay',arguments);
6+
}
7+
48
constructor(title?:string){
59
super(arguments);
610
}
711

8-
set(): this{
9-
returnthis.command('set',arguments);
12+
set(){
13+
this.command('set',arguments);
1014
}
1115

12-
reset(): this{
13-
returnthis.command('reset',arguments);
16+
reset(){
17+
this.command('reset',arguments);
1418
}
1519
}
1620

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp