Skip to content

Commit f7aae7c

Browse files
refactor: replace deprecated String.prototype.substr() (#1782)
* refactor: replace deprecated String.prototype.substr() .substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated Signed-off-by: Tobias Speicher <rootcommander@gmail.com> * Resolve PR comment Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
1 parent bff6cdb commit f7aae7c

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

docs/lcd-i2c-PCF8574.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var board = new five.Board();
3333
board.on("ready", function() {
3434

3535

36-
var random = Math.random().toString(36).replace(/[^a-z]+/g, "").substr(0, 4).toUpperCase();
36+
var random = Math.random().toString(36).replace(/[^a-z]+/g, "").slice(0, 4).toUpperCase();
3737

3838
// Controller: PARALLEL (default)
3939
var p = new five.LCD({

eg/lcd-all.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var board = new five.Board();
44
board.on("ready", function() {
55

66

7-
var random = Math.random().toString(36).replace(/[^a-z]+/g, "").substr(0, 4).toUpperCase();
7+
var random = Math.random().toString(36).replace(/[^a-z]+/g, "").slice(0, 4).toUpperCase();
88

99
// Controller: PARALLEL (default)
1010
var p = new five.LCD({

eg/lcd-i2c-PCF8574.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var board = new five.Board();
44
board.on("ready", function() {
55

66

7-
var random = Math.random().toString(36).replace(/[^a-z]+/g, "").substr(0, 4).toUpperCase();
7+
var random = Math.random().toString(36).replace(/[^a-z]+/g, "").slice(0, 4).toUpperCase();
88

99
// Controller: PARALLEL (default)
1010
var p = new five.LCD({

lib/led/ledcontrol.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ const Controllers = {
674674
throw new Error("The `row` method is only supported for Matrix devices");
675675
}
676676
if (typeof val === "number") {
677-
val = (`0000000000000000${parseInt(val, 10).toString(2)}`).substr(0 - (this.columns), this.columns);
677+
val = (`0000000000000000${parseInt(val, 10).toString(2)}`).slice(0 - (this.columns));
678678
}
679679
if (arguments.length === 2) {
680680
val = row;

0 commit comments

Comments
 (0)