Skip to content

Commit 5394724

Browse files
committed
Enable method chaining for static methods as well
1 parent 1998c19 commit 5394724

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
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.0",
3+
"version": "2.3.1",
44
"description": "Visualization Library for JavaScript",
55
"keywords": [
66
"algorithm",

src/Commander.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Commander {
1414
private static objectCount = 0;
1515
public static commands: Command[] = [];
1616

17-
static command(key: string | null, method: string, iArguments: IArguments): void {
17+
static command(key: string | null, method: string, iArguments: IArguments): Commander {
1818
const args = Array.from(iArguments);
1919
this.commands.push({
2020
key,
@@ -23,14 +23,15 @@ class Commander {
2323
});
2424
if (this.commands.length > MAX_COMMANDS) throw new Error('Too Many Commands');
2525
if (this.objectCount > MAX_OBJECTS) throw new Error('Too Many Objects');
26+
return (<any>this);
2627
}
2728

28-
static setRoot(child: Commander) {
29-
this.command(null, 'setRoot', arguments);
29+
static setRoot(child: Commander): Commander {
30+
return this.command(null, 'setRoot', arguments);
3031
}
3132

32-
static delay(lineNumber?: Number) {
33-
this.command(null, 'delay', arguments);
33+
static delay(lineNumber?: Number): Commander {
34+
return this.command(null, 'delay', arguments);
3435
}
3536

3637
private readonly key: string;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy