Skip to content

Commit 5c86c4b

Browse files
ryanjgillrwaldron
authored andcommitted
using global board with arrow function
1 parent 3de27cf commit 5c86c4b

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

eg/led-array.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const {Board, Leds} = require("../lib/johnny-five.js");
22
const board = new Board();
33

4-
board.on("ready", function() {
4+
board.on("ready", () => {
55
const array = new Leds([3, 5, 6]);
66

77
array.pulse();

eg/led-status.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
// Led.isOn, and Led.isRunning following a variety
44
// of Led method calls.
55
//
6-
var five = require("../lib/johnny-five.js");
7-
var board = new five.Board();
6+
const {Board, Led} = require("../lib/johnny-five.js");
7+
const board = new Board();
88

9-
board.on("ready", function() {
9+
board.on("ready", () => {
1010
// Default to pin 11 (must be PWM)
11-
var led = new five.Led(process.argv[2] || 11);
11+
const led = new Led(process.argv[2] || 11);
1212

13-
this.repl.inject({
14-
led: led
15-
});
13+
board.repl.inject({ led });
1614

1715
// Print defaut status
1816
console.log("default status");
@@ -40,7 +38,7 @@ board.on("ready", function() {
4038
status();
4139

4240
// Wait 3 seconds, stop, and print status
43-
this.wait(3000, function() {
41+
board.wait(3000, () => {
4442
console.log("led.stop()");
4543
led.stop();
4644
// Note that value/isOn will reflect the state of

eg/led.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
const {Board, Led} = require("../lib/johnny-five.js");
22
const board = new Board();
33

4-
board.on("ready", function () {
4+
board.on("ready", () => {
55
const led = new Led(13);
66

77
// This will grant access to the led instance
88
// from within the REPL that's created when
99
// running this program.
10-
this.repl.inject({
10+
board.repl.inject({
1111
led
1212
});
1313

0 commit comments

Comments
 (0)