Skip to content

Commit 736b854

Browse files
committed
Fix column name indexing for p5.Table
1 parent 161f41d commit 736b854

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/io/p5.Table.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ class Table {
259259
// try the Object
260260
if (typeof column === 'string') {
261261
for (let i = 0; i < this.rows.length; i++) {
262-
if (this.rows[i].obj[column] === value) {
262+
if (this.rows[i].obj[this.columns.indexOf(column)] === value) {
263263
return this.rows[i];
264264
}
265265
}
@@ -324,7 +324,7 @@ class Table {
324324
const ret = [];
325325
if (typeof column === 'string') {
326326
for (let i = 0; i < this.rows.length; i++) {
327-
if (this.rows[i].obj[column] === value) {
327+
if (this.rows[i].obj[this.columns.indexOf(column)] === value) {
328328
ret.push(this.rows[i]);
329329
}
330330
}
@@ -387,7 +387,7 @@ class Table {
387387
}
388388
} else {
389389
for (let i = 0; i < this.rows.length; i++) {
390-
if (this.rows[i].obj[column].match(regexp)) {
390+
if (this.rows[i].obj[this.columns.indexOf(column)].match(regexp)) {
391391
return this.rows[i];
392392
}
393393
}
@@ -454,7 +454,7 @@ class Table {
454454
}
455455
} else {
456456
for (let i = 0; i < this.rows.length; i++) {
457-
if (this.rows[i].obj[column].match(regexp)) {
457+
if (this.rows[i].obj[this.columns.indexOf(column)].match(regexp)) {
458458
ret.push(this.rows[i]);
459459
}
460460
}

0 commit comments

Comments
 (0)