Skip to content

Commit 04a3dff

Browse files
committed
allow method chaining setup()
`setup()` returns `this`, which allows for an easier transition from old code: ``` var board = new arduino.Board(); // old var board = new arduino.Board().setup(); // new ```
1 parent 9d89ca6 commit 04a3dff

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/board.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ Board.prototype.setup = function() {
7777
}
7878
}
7979
});
80+
return this;
8081
}
8182

8283
/*
@@ -238,8 +239,8 @@ Board.prototype.analogRead = function (pin) {
238239
* Utility function to pause for a given time
239240
*/
240241
Board.prototype.delay = function (ms) {
241-
ms += +new Date();
242-
while (+new Date() < ms) { }
242+
ms += Date.now();
243+
while (Date.now() < ms) { }
243244
}
244245

245246
/*

0 commit comments

Comments
 (0)